summaryrefslogtreecommitdiff
path: root/tools/get-scala-commit-sha
diff options
context:
space:
mode:
Diffstat (limited to 'tools/get-scala-commit-sha')
-rwxr-xr-xtools/get-scala-commit-sha14
1 files changed, 9 insertions, 5 deletions
diff --git a/tools/get-scala-commit-sha b/tools/get-scala-commit-sha
index eab90a4215..18289c7ca8 100755
--- a/tools/get-scala-commit-sha
+++ b/tools/get-scala-commit-sha
@@ -10,9 +10,13 @@
[[ $# -eq 0 ]] || cd "$1"
-# printf %016s is not portable for 0-padding, has to be a digit.
-# so we're stuck disassembling it.
-hash=$(git log -1 --format="%H" HEAD)
-hash=${hash#g}
-hash=${hash:0:10}
+if git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
+ # printf %016s is not portable for 0-padding, has to be a digit.
+ # so we're stuck disassembling it.
+ hash=$(git log -1 --format="%H" HEAD)
+ hash=${hash#g}
+ hash=${hash:0:10}
+else
+ hash="unknown"
+fi
echo "$hash"