From: Aaron Schrab <aa...@schrab.com>

If not able to use mercurial to build a detailed version string, try
using git to do so.
---
 version.sh |   26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/version.sh b/version.sh
index 39709a0..54568ac 100644
--- a/version.sh
+++ b/version.sh
@@ -64,6 +64,32 @@ if [ -d .hg ] && $HG >/dev/null 2>&1; then
        exit 0
 fi
 
+# If in a git repo, and git is present use that to build detailed version 
string
+if git rev-parse 2> /dev/null; then
+       version=`git describe --long --dirty --tags --match mutt-*-rel`
+
+       case "$version" in
+         *-dirty)
+               dirty=+
+               version=${version%-dirty}
+               ;;
+       esac
+
+       commit=${version##*-}
+       version=${version%-*}
+
+       distance=${version##*-}
+       version=${version%-*}
+
+       version=${version#mutt-}
+       version=${version%-rel}
+
+       version=`echo $version | tr - .`
+
+       echo "$version+$distance ($commit$dirty)"
+       exit 0
+fi
+
 # If nothing else worked, just cat the VERSION file;
 # it contains the latest release number.
 cat VERSION
-- 
1.7.10.4

Reply via email to