diff options
author | Adriaan Moors <adriaan@lightbend.com> | 2016-09-26 16:16:21 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-26 16:16:21 -0700 |
commit | d35a7bde94b6c7b1626bd6085a646a352da7cee2 (patch) | |
tree | 6d25d112c4bcc775cde30e5730e1c221eecff827 | |
parent | 339fc61296de44e05d7a5f3d4d8dd2a146d24eeb (diff) | |
parent | 4874a242cbb72eb94ed71824e81314980cbff024 (diff) | |
download | scala-d35a7bde94b6c7b1626bd6085a646a352da7cee2.tar.gz scala-d35a7bde94b6c7b1626bd6085a646a352da7cee2.tar.bz2 scala-d35a7bde94b6c7b1626bd6085a646a352da7cee2.zip |
Merge pull request #5411 from gourlaysama/ticket/sd-220-build-without-git
Build without being in a git repository
Fix scala-dev#220
-rwxr-xr-x | tools/get-scala-commit-date | 9 | ||||
-rwxr-xr-x | tools/get-scala-commit-sha | 14 |
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" |