Skip to content

Commit eaa3715

Browse files
committed
Hardening get-scala-version.
Reimplementing without git-describe to harden against old gits and make any kind of reference tag unnecessary.
1 parent 8788965 commit eaa3715

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

tools/get-scala-revision

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1-
#!/bin/sh
1+
#!/usr/bin/env bash
22
#
33
# Usage: get-scala-revision [dir]
44
# Figures out current scala revision of a git clone.
55
#
66
# If no dir is given, current working dir is used.
77

8-
[ -n "$1" ] && cd "$1"
8+
# not like releases come out so often that we are duty-bound
9+
# to recalculate this every time.
10+
# git merge-base v2.9.1 master
11+
devbase="d6f3184fc8"
912

10-
# dev should be a tag at the merge-base of master and the
11-
# most recent release.
12-
if [ -z $(git tag -l dev) ]; then
13-
# no dev tag available - this will generate dev-g<sha>
14-
echo "dev-g$(git describe HEAD --abbrev=7 --always)"
15-
else
16-
# dev tag exists - this generates dev-NNNN-g<sha>
17-
# where NNNN is the number of commits since dev.
18-
git describe HEAD --abbrev=7 --match dev
19-
fi
13+
# reimplementing git describe hopefully in a way which works
14+
# without any particular tags, branches, or recent versions of git.
15+
# this is supposed to generate
16+
# dev-NNNN-g<sha>
17+
# where NNNN is the number of commits since devbase, which
18+
# is the merge-base of the most recent release and master.
19+
# Presently hardcoded to reduce uncertainty, v2.9.1/master.
20+
commits=$(GIT_PAGER=cat git log --oneline $devbase..HEAD | wc -l)
21+
sha=$(git log -1 --abbrev-commit --abbrev=7 --format="%h")
22+
printf "dev-%s-g%s\n" $commits $sha

0 commit comments

Comments
 (0)