|
11 | 11 | [[ $# -eq 0 ]] || cd "$1"
|
12 | 12 |
|
13 | 13 | ensure_tag () {
|
14 |
| - # v2.10.0-M1 |
15 |
| - fallback=58cb15c40d |
16 |
| - [[ -n $(git tag -l v2.10.0-M1) ]] || { |
17 |
| - git tag -a -m "generated by get-scala-revision" v2.10.0-M1 $fallback |
| 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 |
18 | 19 | }
|
19 | 20 | }
|
20 |
| -ensure_tag |
| 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 |
21 | 28 |
|
22 | 29 | # the closest tag, obtained separately because we have to
|
23 | 30 | # reconstruct the string around the padded distance.
|
24 |
| -tag=$(git describe --match 'v2*' --abbrev=0) |
| 31 | +tag=$(git describe --tags --match 'v2*' --abbrev=0) |
25 | 32 |
|
26 |
| -# the full string - padding correctness depends on abbrev=10. |
27 |
| -described=$(git describe --match 'v2*' --abbrev=10) |
| 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) |
28 | 36 | suffix="${described##${tag}-}"
|
29 | 37 | counter=$(echo $suffix | cut -d - -f 1)
|
30 | 38 | hash=$(echo $suffix | cut -d - -f 2)
|
31 | 39 |
|
32 |
| -# 016 is rocket-surgically-calibrated to pad the distance from the |
33 |
| -# tag to the current commit into a 4-digit number - since maven |
34 |
| -# will be treating this as a string, the ide depends on |
35 |
| -# 10 being greater than 9 (thus 0010 and 00009.) |
36 |
| -printf "%s-%04d-%10s-%s\n" "$tag" "$counter" "$hash" $(date "+%Y-%m-%d") |
| 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