diff options
author | Josh Suereth <Joshua.Suereth@gmail.com> | 2012-03-16 09:10:47 -0700 |
---|---|---|
committer | Josh Suereth <Joshua.Suereth@gmail.com> | 2012-03-16 09:10:47 -0700 |
commit | 06765bf3660db2e11c6fe3a85db3b25373c2c9ed (patch) | |
tree | 5f6bd3909b69666c625dc6e3a14d1596c4f20303 /tools/get-scala-commit-sha | |
parent | 125b5037c866fd6db771cf78de44479588e8f118 (diff) | |
parent | 243c62957ec4b583095bc5e170908043263e5f2a (diff) | |
download | scala-06765bf3660db2e11c6fe3a85db3b25373c2c9ed.tar.gz scala-06765bf3660db2e11c6fe3a85db3b25373c2c9ed.tar.bz2 scala-06765bf3660db2e11c6fe3a85db3b25373c2c9ed.zip |
Merge pull request #271 from jsuereth/2.9.x-version-fixinv2.9.2-RC1
2.9.x version fixin
Diffstat (limited to 'tools/get-scala-commit-sha')
-rwxr-xr-x | tools/get-scala-commit-sha | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tools/get-scala-commit-sha b/tools/get-scala-commit-sha new file mode 100755 index 0000000000..0abe31a53c --- /dev/null +++ b/tools/get-scala-commit-sha @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +# +# Usage: get-scala-commit-sha [dir] +# Figures out current commit sha of a git clone. +# If no dir is given, current working dir is used. +# +# Example build version string: +# 6f1c486d0ba +# + +[[ $# -eq 0 ]] || cd "$1" + +ensure_tag () { + sha=$1 + rev=$2 + + [[ -n $(git tag -l $rev) ]] || { + git tag -a -m "generated by get-scala-revision" $rev $sha + } +} + +# Ensure some baseline tags are present so if this repository's +# tags are screwed up or stale, we should still have a reference +# point for a build string. +ensure_tag 58cb15c40d v2.10.0-M1 +ensure_tag 29f3eace1e v2.9.1 +ensure_tag b0d78f6b9c v2.8.2 + +# the closest tag, obtained separately because we have to +# reconstruct the string around the padded distance. +tag=$(git describe --tags --match 'v2*' --abbrev=0) + +# printf %016s is not portable for 0-padding, has to be a digit. +# so we're stuck disassembling it. +described=$(git describe --tags --match 'v2*' --abbrev=10) +suffix="${described##${tag}-}" +hash=$(echo $suffix | cut -d - -f 2) +hash=${hash#g} + +echo "$hash" |