summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAntoine Gourlay <antoine@gourlay.fr>2016-09-20 16:00:53 +0200
committerAntoine Gourlay <antoine@gourlay.fr>2016-09-20 16:00:53 +0200
commit4874a242cbb72eb94ed71824e81314980cbff024 (patch)
tree05d02ccc6b6fd7d09f34aaa1ee7390390b55216e /tools
parent05016d9035ab9b1c866bd9f12fdd0491f1ea0cbb (diff)
downloadscala-4874a242cbb72eb94ed71824e81314980cbff024.tar.gz
scala-4874a242cbb72eb94ed71824e81314980cbff024.tar.bz2
scala-4874a242cbb72eb94ed71824e81314980cbff024.zip
SD-220 building without being in a git repository
This allows building from the scala sources tarball or similar situations where there is no local git repository: - the git commit date becomes the local date - the short git sha1 becomes "unknown" ``` Welcome to Scala 2.12.0-20160920-155429-unknown (OpenJDK 64-Bit Server VM, Java 1.8.0_102). ```
Diffstat (limited to 'tools')
-rwxr-xr-xtools/get-scala-commit-date9
-rwxr-xr-xtools/get-scala-commit-sha14
2 files changed, 16 insertions, 7 deletions
diff --git a/tools/get-scala-commit-date b/tools/get-scala-commit-date
index b2e4e10770..6511ed98ca 100755
--- a/tools/get-scala-commit-date
+++ b/tools/get-scala-commit-date
@@ -10,8 +10,13 @@
[[ $# -eq 0 ]] || cd "$1"
-lastcommitdate=$(git log --format="%ci" HEAD | head -n 1 | cut -d ' ' -f 1)
-lastcommithours=$(git log --format="%ci" HEAD | head -n 1 | cut -d ' ' -f 2)
+if git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
+ lastcommitdate=$(git log --format="%ci" HEAD | head -n 1 | cut -d ' ' -f 1)
+ lastcommithours=$(git log --format="%ci" HEAD | head -n 1 | cut -d ' ' -f 2)
+else
+ lastcommitdate=$(date +%Y-%m-%d)
+ lastcommithours=$(date +%H:%M:%S)
+fi
# 20120324
echo "${lastcommitdate//-/}-${lastcommithours//:/}"
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"