From d92a81bf2dc2e36f2eb5975481f273af47bee909 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 7 Aug 2022 18:39:08 +0200 Subject: [PATCH] feat(lib): add lib/git Where future git wrappers will live. --- lisp/lib/git.el | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 lisp/lib/git.el diff --git a/lisp/lib/git.el b/lisp/lib/git.el new file mode 100644 index 000000000..dc5d82dc1 --- /dev/null +++ b/lisp/lib/git.el @@ -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))))