Skip to content

Commit dbb8d98

Browse files
committed
Merge branch 'fix-script' into 2.8.x
2 parents 2229f69 + 69c2eb5 commit dbb8d98

File tree

1 file changed

+33
-16
lines changed

1 file changed

+33
-16
lines changed

tools/get-scala-revision

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,40 @@
22
#
33
# Usage: get-scala-revision [dir]
44
# Figures out current scala revision of a git clone.
5-
#
65
# If no dir is given, current working dir is used.
6+
#
7+
# Example build version string:
8+
# v2.10.0-M1-0098-g6f1c486d0b-2012-02-01
9+
#
10+
11+
[[ $# -eq 0 ]] || cd "$1"
12+
13+
ensure_tag () {
14+
sha=$1
15+
rev=$2
16+
17+
[[ -n $(git tag -l $rev) ]] || {
18+
git tag -a -m "generated by get-scala-revision" $rev $sha
19+
}
20+
}
21+
22+
# Ensure some baseline tags are present so if this repository's
23+
# tags are screwed up or stale, we should still have a reference
24+
# point for a build string.
25+
ensure_tag 58cb15c40d v2.10.0-M1
26+
ensure_tag 29f3eace1e v2.9.1
27+
ensure_tag b0d78f6b9c v2.8.2
728

8-
# not like releases come out so often that we are duty-bound
9-
# to recalculate this every time.
10-
# git merge-base v2.8.2 v2.9.1 master
11-
devbase="df13e31bbb"
29+
# the closest tag, obtained separately because we have to
30+
# reconstruct the string around the padded distance.
31+
tag=$(git describe --tags --match 'v2*' --abbrev=0)
1232

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.8.2/v2.9.1/master.
20-
commits=$(git --no-pager log --pretty=oneline $devbase..HEAD | wc -l)
21-
sha=$(git rev-list -n 1 HEAD)
22-
datestr=$(date "+%Y-%m-%d")
33+
# printf %016s is not portable for 0-padding, has to be a digit.
34+
# so we're stuck disassembling it.
35+
described=$(git describe --tags --match 'v2*' --abbrev=10)
36+
suffix="${described##${tag}-}"
37+
counter=$(echo $suffix | cut -d - -f 1)
38+
hash=$(echo $suffix | cut -d - -f 2)
2339

24-
printf "rdev-%s-%s-g%s\n" $commits $datestr ${sha:0:7}
40+
# v2.10.0-M1-0098-g6f1c486d0b-2012-02-01
41+
printf "%s-%04d-%s-%s\n" "$tag" "$counter" "$hash" $(date "+%Y-%m-%d")

0 commit comments

Comments
 (0)