]> granicus.if.org Git - mutt/commitdiff
Change version.sh to manually compute version and distance.
authorAaron Schrab <aaron+mutt@schrab.com>
Tue, 12 Dec 2017 02:46:30 +0000 (21:46 -0500)
committerKevin McCarthy <kevin@8t8.us>
Wed, 13 Dec 2017 01:40:28 +0000 (17:40 -0800)
In some cases `git describe` gives bizarre results (see URL below),
instead get the highest version-numbered tag contained in HEAD then
count the number of commits that aren't included in it.

https://public-inbox.org/git/20161205232712.GA23868@pug.qqx.org/

version.sh

index 4bf5fdf2cad7f7cb0ddfed8c1df99aaa837b2c55..5b3b222ef2038a5c95f31ee7020801b39f45bbcf 100644 (file)
@@ -9,28 +9,13 @@ srcdir=`dirname "$0"` && cd "$srcdir" || exit 1
 # If not, just cat the VERSION file; it contains the latest release number.
 [ -d ".git" ] || exec cat VERSION
 
-# translate release tags into ##.##.## notation
-get_tag () {
-       sed -e 's/mutt-//' -e 's/-rel.*//' | tr - .
-}
-
-get_dist_node() {
-       sed -e 's/.*-rel-//' -e 's/-/ /'
-}
-
-describe=`git describe --tags --long --match 'mutt-*-rel' 2>/dev/null` || exec cat VERSION
-
-tag=`echo $describe | get_tag`
-
-set -- `echo $describe | get_dist_node`
-dist="$1"
-node="$2"
-
-if [ $dist -eq 0 ]; then
-       dist=
+latesttag="$(git tag --merged=HEAD --list 'mutt-*-rel' | tr - . | sort -Vr | head -n1 | tr . -)"
+version="$(echo $latesttag | sed -e s/mutt-// -e s/-rel// -e s/-/./g)"
+distance="$(git rev-list --count $latesttag..)"
+commitid="$(git rev-parse --short HEAD)"
+if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
+  dirty=+
 else
-       dist="+$dist"
+  dirty=""
 fi
-
-echo "$tag$dist ($node)"
-exit 0
+echo "${version}+${distance} (g${commitid}${dirty})"