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