blob: eac512a010682f189a75824365595e39938086c2 (
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
25
26
27
|
#!/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)
suffix="${described##${tag}-}"
counter=$(echo $suffix | cut -d - -f 1)
hash=$(echo $suffix | cut -d - -f 2)
# 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-%04d-%10s-%s\n" "$tag" "$counter" "$hash" $(date "+%Y-%m-%d")
|