feat(lib): add lib/git

Where future git wrappers will live.
This commit is contained in:
Henrik Lissner 2022-08-07 18:39:08 +02:00
parent b7b2563f7b
commit d92a81bf2d
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

11
lisp/lib/git.el Normal file
View file

@ -0,0 +1,11 @@
;;; lisp/lib/git.el -*- lexical-binding: t; -*-
;;;###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))))