doomemacs/lisp/lib/git.el
Henrik Lissner b121c5e1c6
refactor(lib): provide doom-libs as subfeatures
This allows us to load them via doom-require. Why not use normal
features? Because Doom's libraries are designed to be loaded as part of
Doom, and will openly rely on Doom state if needed; this is a contract I
want to enforce by ensuring their only entry points are through
`doom-require` or autoloading.

I will add them to the rest of the libraries later.

Site-node: this also adds Commentary+Code to the comment headings, as I
want a space to use that space to describe the library, when I get
around to it.
2022-09-08 00:20:26 +02:00

17 lines
504 B
EmacsLisp

;;; lisp/lib/git.el -*- lexical-binding: t; -*-
;;; Commentary:
;;; Code:
;;;###autoload
(defun doom-git-toplevel (&rest segments)
"Return the path to the current repo's root."
(cl-destructuring-bind (code . output)
(doom-call-process "git" "rev-parse" "--show-toplevel")
(if (zerop code)
(apply #'file-name-concat output segments)
;; TODO throw stderr as error
(user-error "Not in a git repo: %s" default-directory))))
(provide 'doom-lib '(git))
;;; git.el ends here