summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtools/get-scala-revision27
1 files changed, 15 insertions, 12 deletions
diff --git a/tools/get-scala-revision b/tools/get-scala-revision
index e8597844cc..dc0ee561dd 100755
--- a/tools/get-scala-revision
+++ b/tools/get-scala-revision
@@ -1,19 +1,22 @@
-#!/bin/sh
+#!/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.
-[ -n "$1" ] && cd "$1"
+# 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"
-# dev should be a tag at the merge-base of master and the
-# most recent release.
-if [ -z $(git tag -l dev) ]; then
- # no dev tag available - this will generate dev-g<sha>
- echo "dev-g$(git describe HEAD --abbrev=7 --always)"
-else
- # dev tag exists - this generates dev-NNNN-g<sha>
- # where NNNN is the number of commits since dev.
- git describe HEAD --abbrev=7 --match dev
-fi
+# 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.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