From: Aaron Schrab Date: Tue, 12 Dec 2017 02:46:30 +0000 (-0500) Subject: Change version.sh to manually compute version and distance. X-Git-Tag: mutt-1-9-2-rel~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8648db83acda1d19cef8f32688fd176cbfae3a18;p=mutt Change version.sh to manually compute version and distance. 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/ --- diff --git a/version.sh b/version.sh index 4bf5fdf2..5b3b222e 100644 --- a/version.sh +++ b/version.sh @@ -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})"