[muddle] [PATCH] Compute the version number dynamically

Jason Self j at jxself.org
Sat Mar 3 07:49:18 PST 2018

This creates a generated version number. When not on the master
branch (i.e., a release branch) it uses git describe --tags to return
either the exact release tag or if on a later commit (because there
was a fix made to a released version) then the command returns that
tag plus the number of commits since that tag along with the short
hash. When on the master branch, which has no tags, it returns a
similiar output.

Signed-off-by: Jason Self <j at jxself.org>
 version.sh | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
 create mode 100755 version.sh

diff --git a/version.sh b/version.sh
new file mode 100755
index 0000000..f3302bb
--- /dev/null
+++ b/version.sh
@@ -0,0 +1,15 @@
+# Copyright (C) 2018 Jason Self <j at 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" ]
+    git describe --tags
+    commit_count=$(git rev-list HEAD --count)
+    short_hash=$(git rev-parse --short HEAD)
+    echo "$branch-$commit_count-$short_hash"
\ No newline at end of file

More information about the muddle mailing list