Skip to content

Commit d56bf52

Browse files
authored
chore(scripts): support Sapling in project_root (#8685)
1 parent 9833cd3 commit d56bf52

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

scripts/lib.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,19 @@ realpath() {
4141
# We have to define realpath before these otherwise it fails on Mac's bash.
4242
SCRIPT="${BASH_SOURCE[1]:-${BASH_SOURCE[0]}}"
4343
SCRIPT_DIR="$(realpath "$(dirname "$SCRIPT")")"
44-
PROJECT_ROOT="$(cd "$SCRIPT_DIR" && realpath "$(git rev-parse --show-toplevel)")"
44+
45+
function project_root {
46+
# Try to use `git rev-parse --show-toplevel` to find the project root.
47+
# If this directory is not a git repository, this command will fail.
48+
git rev-parse --show-toplevel 2>/dev/null && return
49+
50+
# This finds the Sapling root. This behavior is added so that @ammario
51+
# and others can more easily experiment with Sapling, but we do not have a
52+
# plan to support Sapling across the repo.
53+
sl root 2>/dev/null && return
54+
}
55+
56+
PROJECT_ROOT="$(cd "$SCRIPT_DIR" && realpath "$(project_root)")"
4557

4658
# pushd is a silent alternative to the real pushd shell command.
4759
pushd() {

0 commit comments

Comments
 (0)