2005-12-27 22:40:17 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
GVF=GIT-VERSION-FILE
|
2018-12-01 12:44:56 +00:00
|
|
|
DEF_VER=v2.20.0-rc2
|
2005-12-27 22:40:17 +00:00
|
|
|
|
2006-08-08 20:11:16 +00:00
|
|
|
LF='
|
|
|
|
'
|
|
|
|
|
2007-02-14 19:33:04 +00:00
|
|
|
# First see if there is a version file (included in release tarballs),
|
|
|
|
# then try git-describe, then default.
|
|
|
|
if test -f version
|
2006-03-02 22:38:44 +00:00
|
|
|
then
|
2006-01-26 16:39:27 +00:00
|
|
|
VN=$(cat version) || VN="$DEF_VER"
|
2013-06-15 23:01:11 +00:00
|
|
|
elif test -d ${GIT_DIR:-.git} -o -f .git &&
|
2016-12-04 20:45:59 +00:00
|
|
|
VN=$(git describe --match "v[0-9]*" HEAD 2>/dev/null) &&
|
2007-02-14 19:33:04 +00:00
|
|
|
case "$VN" in
|
|
|
|
*$LF*) (exit 1) ;;
|
2008-02-17 06:44:31 +00:00
|
|
|
v[0-9]*)
|
2008-08-08 20:31:27 +00:00
|
|
|
git update-index -q --refresh
|
2008-06-28 17:13:29 +00:00
|
|
|
test -z "$(git diff-index --name-only HEAD --)" ||
|
2008-02-23 19:31:04 +00:00
|
|
|
VN="$VN-dirty" ;;
|
2007-02-14 19:33:04 +00:00
|
|
|
esac
|
|
|
|
then
|
|
|
|
VN=$(echo "$VN" | sed -e 's/-/./g');
|
2006-03-02 22:38:44 +00:00
|
|
|
else
|
|
|
|
VN="$DEF_VER"
|
2006-01-26 16:39:27 +00:00
|
|
|
fi
|
2006-01-10 02:07:01 +00:00
|
|
|
|
|
|
|
VN=$(expr "$VN" : v*'\(.*\)')
|
2006-01-09 22:25:10 +00:00
|
|
|
|
2005-12-27 22:40:17 +00:00
|
|
|
if test -r $GVF
|
|
|
|
then
|
|
|
|
VC=$(sed -e 's/^GIT_VERSION = //' <$GVF)
|
|
|
|
else
|
|
|
|
VC=unset
|
|
|
|
fi
|
|
|
|
test "$VN" = "$VC" || {
|
|
|
|
echo >&2 "GIT_VERSION = $VN"
|
|
|
|
echo "GIT_VERSION = $VN" >$GVF
|
|
|
|
}
|