~kevin8t8/mutt

ref: 2fbc29ec127aa3d699def01e574f14996db8cacc mutt/version.sh -rw-r--r-- 800 bytes
2fbc29ecKevin McCarthy Allow my_var assignments to reference the $my_var in the value. 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh

# Switch to directory where this script lives so that further commands are run
# from the root directory of the source.  The script path and srcdir are double
# quoted to allow the space character to appear in the path.
srcdir=`dirname "$0"` && cd "$srcdir" || exit 1

# Ensure that we have a repo here.
# If not, just cat the VERSION file; it contains the latest release number.
{ [ -r ".git" ] && command -v git >/dev/null 2>&1; } \
|| exec cat VERSION

latesttag=`git describe --tags --match 'mutt-*-rel' --abbrev=0`
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 [ $distance -eq 0 ]; then
  distance=
else
  distance="+$distance"
fi

echo "${version}${distance} (${commitid})"