#!/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")