summaryrefslogtreecommitdiff
path: root/tools/get-scala-revision
blob: b27b6ddc8268e02fcb425a02c55bac1548ec5382 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/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.8.2 v2.9.1 master
devbase="df13e31bbb"

# 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.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")

printf "rdev-%s-%s-g%s\n" $commits $datestr ${sha:0:7}