2005-12-27 23:40:17 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
GVF=GIT-VERSION-FILE
|
2006-04-08 03:02:40 +02:00
|
|
|
DEF_VER=v1.3-rc3.GIT
|
2005-12-27 23:40:17 +01:00
|
|
|
|
2006-01-10 03:07:01 +01:00
|
|
|
# First try git-describe, then see if there is a version file
|
|
|
|
# (included in release tarballs), then default
|
2006-01-26 17:39:27 +01:00
|
|
|
if VN=$(git-describe --abbrev=4 HEAD 2>/dev/null); then
|
|
|
|
VN=$(echo "$VN" | sed -e 's/-/./g');
|
2006-03-02 23:38:44 +01:00
|
|
|
elif test -f version
|
|
|
|
then
|
2006-01-26 17:39:27 +01:00
|
|
|
VN=$(cat version) || VN="$DEF_VER"
|
2006-03-02 23:38:44 +01:00
|
|
|
else
|
|
|
|
VN="$DEF_VER"
|
2006-01-26 17:39:27 +01:00
|
|
|
fi
|
2006-01-10 03:07:01 +01:00
|
|
|
|
|
|
|
VN=$(expr "$VN" : v*'\(.*\)')
|
2006-01-09 23:25:10 +01:00
|
|
|
|
|
|
|
dirty=$(sh -c 'git-diff-index --name-only HEAD' 2>/dev/null) || dirty=
|
|
|
|
case "$dirty" in
|
|
|
|
'')
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
VN="$VN-dirty" ;;
|
|
|
|
esac
|
|
|
|
|
2005-12-27 23:40:17 +01: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
|
|
|
|
}
|
|
|
|
|
|
|
|
|