feat(tools/magrathea): let users override the repository root

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>
This commit is contained in:
Vincent Ambo 2021-12-18 01:52:22 +03:00 committed by tazjin
parent 46a4e25550
commit 8fb90b9e5e

View file

@ -168,9 +168,10 @@ USAGE
(or mg--repository-root
(begin
(set! mg--repository-root
(or (get-environment-variable "MG_ROOT")
(string-chomp
(call-with-input-pipe "git rev-parse --show-toplevel"
(lambda (p) (read-string #f p)))))
(lambda (p) (read-string #f p))))))
mg--repository-root)))
;; determine the current path relative to the root of the repository