Compute the version number dynamically
[muddle-interpreter.git] / version.sh
diff --git a/version.sh b/version.sh
new file mode 100755 (executable)
index 0000000..f3302bb
--- /dev/null
@@ -0,0 +1,15 @@
+# Copyright (C) 2018 Jason Self <j@jxself.org>
+# Copying and distribution of this file, with or without
+# modification, are permitted in any medium without royalty provided
+# the copyright notice and this notice are preserved. This file is
+# offered as-is, without any warranty.
+
+branch=$(git rev-parse --abbrev-ref HEAD)
+if [ "$branch" != "master" ]
+then
+    git describe --tags
+else
+    commit_count=$(git rev-list HEAD --count)
+    short_hash=$(git rev-parse --short HEAD)
+    echo "$branch-$commit_count-$short_hash"
+fi
\ No newline at end of file