about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2021-12-17T22·52+0300
committertazjin <mail@tazj.in>2021-12-18T15·03+0000
commit8fb90b9e5eb58bc8e1820f4c8c8fd65bcc0031dd (patch)
tree92fc05cd2a53551096ada4e1ddcf5ec8171a5342
parent46a4e25550456790999c3afe4a578dedb8fe5024 (diff)
feat(tools/magrathea): let users override the repository root r/3292
for global installations of magrathea, setting MG_ROOT can be a way to
switch quickly between different repositories (esp. in combination
with `cd (mg path)`).

Change-Id: I4627fe78b7cc112b75ab57e7806ffd85c6d38aee
Reviewed-on: https://cl.tvl.fyi/c/depot/+/4396
Tested-by: BuildkiteCI
Reviewed-by: wpcarro <wpcarro@gmail.com>
-rw-r--r--tools/magrathea/mg.scm7
1 files changed, 4 insertions, 3 deletions
diff --git a/tools/magrathea/mg.scm b/tools/magrathea/mg.scm
index 38447e9303..990fb87f90 100644
--- a/tools/magrathea/mg.scm
+++ b/tools/magrathea/mg.scm
@@ -168,9 +168,10 @@ USAGE
   (or mg--repository-root
       (begin
         (set! mg--repository-root
-              (string-chomp
-               (call-with-input-pipe "git rev-parse --show-toplevel"
-                                     (lambda (p) (read-string #f p)))))
+              (or (get-environment-variable "MG_ROOT")
+                  (string-chomp
+                   (call-with-input-pipe "git rev-parse --show-toplevel"
+                                         (lambda (p) (read-string #f p))))))
         mg--repository-root)))
 
 ;; determine the current path relative to the root of the repository