summaryrefslogtreecommitdiff
path: root/tools/get-scala-revision
blob: 8d48c8cb78105d2fc00528b0556a840558b4a9f6 (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.
#
# Example build version string:
#   v2.10.0-M1-0098-g6f1c486d0b-2012-02-01
#

[[ $# -eq 0 ]] || cd "$1"

# the closest tag, obtained separately because we have to
# reconstruct the string around the padded distance.
tag=$(git describe --abbrev=0)

# the full string - padding correctness depends on abbrev=10.
described=$(git describe --abbrev=10 --always --tags)

# 016 is rocket-surgically-calibrated to pad the distance from the
# tag to the current commit into a 4-digit number - since maven
# will be treating this as a string, the ide depends on
# 10 being greater than 9 (thus 0010 and 00009.)
printf "%s-%016s-%s\n" "$tag" "${described##${tag}-}" $(date "+%Y-%m-%d")