From 7d2db571b41f3c23e91ad27ee5b81a421f312e00 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Fri, 9 Dec 2011 20:45:52 -0800 Subject: Hardening get-scala-version. Reimplementing without git-describe to harden against old gits and make any kind of reference tag unnecessary. Conflicts: tools/get-scala-revision --- tools/get-scala-revision | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 tools/get-scala-revision diff --git a/tools/get-scala-revision b/tools/get-scala-revision new file mode 100755 index 0000000000..dc0ee561dd --- /dev/null +++ b/tools/get-scala-revision @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# +# Usage: get-scala-revision [dir] +# Figures out current scala revision of a git clone. +# +# If no dir is given, current working dir is used. + +# not like releases come out so often that we are duty-bound +# to recalculate this every time. +# git merge-base v2.9.1 master +devbase="d6f3184fc8" + +# 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.9.1/master. +commits=$(GIT_PAGER=cat git log --oneline $devbase..HEAD | wc -l) +sha=$(git log -1 --abbrev-commit --abbrev=7 --format="%h") +printf "dev-%s-g%s\n" $commits $sha -- cgit v1.2.3 From a348cc3f8310bee4b3053412106ecbc21718cc83 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Fri, 9 Dec 2011 21:33:13 -0800 Subject: More on get-scala-revision. Now that I've resorted to building git 1.5.4, I can stop trying to reverse engineer it through jenkins. This implementation feels winnerish. --- tools/get-scala-revision | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/get-scala-revision b/tools/get-scala-revision index dc0ee561dd..3977a61040 100755 --- a/tools/get-scala-revision +++ b/tools/get-scala-revision @@ -17,6 +17,6 @@ devbase="d6f3184fc8" # 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.9.1/master. -commits=$(GIT_PAGER=cat git log --oneline $devbase..HEAD | wc -l) -sha=$(git log -1 --abbrev-commit --abbrev=7 --format="%h") -printf "dev-%s-g%s\n" $commits $sha +commits=$(git --no-pager log --pretty=oneline $devbase..HEAD | wc -l) +sha=$(git rev-list -n 1 HEAD) +printf "dev-%s-g%s\n" $commits ${sha:0:7} -- cgit v1.2.3