summaryrefslogtreecommitdiff
path: root/tools/get-scala-revision
blob: e8597844cc6d8bf80611bf617fa74bf1442b851b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/sh
#
# 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"

# 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