GIT-VERSION-GEN 673 字节
Newer Older
1 2 3
#!/bin/sh

GVF=GIT-VERSION-FILE
4
DEF_VER=v1.5.4.GIT
5

6 7 8
LF='
'

9 10 11
# First see if there is a version file (included in release tarballs),
# then try git-describe, then default.
if test -f version
12
then
13
	VN=$(cat version) || VN="$DEF_VER"
14 15 16 17
elif test -d .git &&
	VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
	case "$VN" in
	*$LF*) (exit 1) ;;
J
Junio C Hamano 已提交
18 19
	v[0-9]*)
		git diff-index --quiet HEAD || VN="$VN-dirty" ;;
20 21 22
	esac
then
	VN=$(echo "$VN" | sed -e 's/-/./g');
23 24
else
	VN="$DEF_VER"
25
fi
26 27

VN=$(expr "$VN" : v*'\(.*\)')
28

29 30 31 32 33 34 35 36 37 38 39 40
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
}