From d01da30e4c2197ec24e29fb77ce9a62435bff9a4 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Wed, 1 Feb 2012 11:21:06 -0800 Subject: Updated get-scala-revision to use git describe. Hopefully this will satisfy all version-interesting parties. Version string now looks like this: v2.10.0-M1-0098-gbda61bb7e5-2012-02-01 Review by @dragos and anyone who uses windows (where it definitely won't produce that string, but hopefully it produces some usable string.) --- tools/get-scala-revision | 32 ++++++++++++++++---------------- tools/get-scala-revision.bat | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/tools/get-scala-revision b/tools/get-scala-revision index b27b6ddc82..8d48c8cb78 100755 --- a/tools/get-scala-revision +++ b/tools/get-scala-revision @@ -2,23 +2,23 @@ # # 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" -# 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 --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 -# 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") +# the full string - padding correctness depends on abbrev=10. +described=$(git describe --abbrev=10 --always --tags) -printf "rdev-%s-%s-g%s\n" $commits $datestr ${sha:0:7} +# 016 is rocket-surgically-calibrated to pad the distance from the +# tag to the current commit into a 4-digit number - since maven +# will be treating this as a string, the ide depends on +# 10 being greater than 9 (thus 0010 and 00009.) +printf "%s-%016s-%s\n" "$tag" "${described##${tag}-}" $(date "+%Y-%m-%d") diff --git a/tools/get-scala-revision.bat b/tools/get-scala-revision.bat index f4dc24b71f..48c7cbd94f 100644 --- a/tools/get-scala-revision.bat +++ b/tools/get-scala-revision.bat @@ -15,7 +15,7 @@ if "%*"=="" ( cd %_DIR% if exist .git\NUL ( - git describe HEAD --abbrev=7 --match dev + git describe --abbrev=10 --always --tags ) :end -- cgit v1.2.3