From: Jason Self Date: Sat, 17 Mar 2018 19:15:51 +0000 (-0700) Subject: Compute the version number dynamically X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;p=muddle-interpreter.git Compute the version number dynamically 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 --- diff --git a/configure.ac b/configure.ac index ddfd339..b53e054 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([muddle], [1.0], [muddle@muddlers.org]) +AC_INIT([muddle], m4_esyscmd_s([./version.sh]), [muddle@muddlers.org]) AM_INIT_AUTOMAKE([-Wall -Werror foreign]) AC_PROG_CC AC_CONFIG_HEADERS([config.h]) 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 +# 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