-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathVERSION-GEN
71 lines (64 loc) · 1.29 KB
/
VERSION-GEN
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
# (c) GIT-VERSION-GEN - github.com/git/git
if [ -z "$VERSION_FILE" ];
then
VF="VERSION-FILE";
else
VF="$VERSION_FILE";
fi
LF='
'
# First see if there is a version file (included in release tarballs),
# then try git-describe, then default.
if test -f version
then
VN=$(cat version) || VN="$VERSION"
elif test -d .git -o -f .git &&
VN=$(git describe --match "v[0-9]*" --tags --abbrev=7 HEAD 2>/dev/null) &&
case "$VN" in
*$LF*) (exit 1) ;;
v[0-9]*)
git update-index -q --refresh
test -z "$(git diff-index --name-only HEAD --)" ||
VN="$VN-dirty" ;;
esac
then
# Format into cygwin version major.minor.micro-release[.<git-describe>]
oldIFS="$IFS";
IFS="-";
i=0;
VT="";
for part in $VN;
do
case "$i"
in
'0')
VT+="$part";
;;
'1')
VT+="-$part";
;;
*)
VT+=".$part";
;;
esac;
(( i++ ));
done;
unset i;
IFS="$oldIFS"
VN="$VT";
else
VN="$VERSION"
fi
VN=$(expr "$VN" : v*'\(.*\)')
if test -r $VF
then
VC=$(sed -e 's/^VERSION = //' <$VF)
else
VC=unset
fi
test "$VN" = "$VC" || {
echo >&2 "VERSION = $VN"
echo "VERSION = $VN" >$VF
}
exit 0;