diff options
author | Paul Phillips <paulp@improving.org> | 2012-02-04 21:36:53 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-02-04 21:36:53 -0800 |
commit | dbb8d98630795f92f187fca451ca97fbae69fe10 (patch) | |
tree | aacddc3944323d256a6b09b37c3dc442d6f7b21d | |
parent | 2229f696474497ae325f7a21353f580222283a9c (diff) | |
parent | 69c2eb5ad21848ab6b326c71c157288432e6a9f5 (diff) | |
download | scala-dbb8d98630795f92f187fca451ca97fbae69fe10.tar.gz scala-dbb8d98630795f92f187fca451ca97fbae69fe10.tar.bz2 scala-dbb8d98630795f92f187fca451ca97fbae69fe10.zip |
Merge branch 'fix-script' into 2.8.x
-rwxr-xr-x | tools/get-scala-revision | 49 |
1 files changed, 33 insertions, 16 deletions
diff --git a/tools/get-scala-revision b/tools/get-scala-revision index b27b6ddc82..8747fdc3fb 100755 --- a/tools/get-scala-revision +++ b/tools/get-scala-revision @@ -2,23 +2,40 @@ # # Usage: get-scala-revision [dir] # Figures out current scala revision of a git clone. -# # If no dir is given, current working dir is used. +# +# Example build version string: +# v2.10.0-M1-0098-g6f1c486d0b-2012-02-01 +# + +[[ $# -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 -# not like releases come out so often that we are duty-bound -# to recalculate this every time. -# git merge-base v2.8.2 v2.9.1 master -devbase="df13e31bbb" +# the closest tag, obtained separately because we have to +# reconstruct the string around the padded distance. +tag=$(git describe --tags --match 'v2*' --abbrev=0) -# reimplementing git describe hopefully in a way which works -# without any particular tags, branches, or recent versions of git. -# this is supposed to generate -# dev-NNNN-g<sha> -# where NNNN is the number of commits since devbase, which -# is the merge-base of the most recent release and master. -# Presently hardcoded to reduce uncertainty, v2.8.2/v2.9.1/master. -commits=$(git --no-pager log --pretty=oneline $devbase..HEAD | wc -l) -sha=$(git rev-list -n 1 HEAD) -datestr=$(date "+%Y-%m-%d") +# 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}-}" +counter=$(echo $suffix | cut -d - -f 1) +hash=$(echo $suffix | cut -d - -f 2) -printf "rdev-%s-%s-g%s\n" $commits $datestr ${sha:0:7} +# v2.10.0-M1-0098-g6f1c486d0b-2012-02-01 +printf "%s-%04d-%s-%s\n" "$tag" "$counter" "$hash" $(date "+%Y-%m-%d") |