summaryrefslogtreecommitdiff
path: root/tools/get-scala-revision
diff options
context:
space:
mode:
Diffstat (limited to 'tools/get-scala-revision')
-rwxr-xr-xtools/get-scala-revision19
1 files changed, 19 insertions, 0 deletions
diff --git a/tools/get-scala-revision b/tools/get-scala-revision
new file mode 100755
index 0000000000..e8597844cc
--- /dev/null
+++ b/tools/get-scala-revision
@@ -0,0 +1,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