forked from ESDAnalysisTools/ThunderStorm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
VERSION-GEN
executable file
·48 lines (40 loc) · 1011 Bytes
/
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
#!/bin/sh
# Tag revisions like this:
# $ git tag -a -m "Version 0.2" v0.2 HEAD
VF=./thunderstorm/__init__.py
DEFAULT_VERSION=UNKNOWN
LF='
'
# First see if there is a version file (included in release tarballs),
# then try git-describe, then default.
if test -d .git -o -f .git &&
VN=$(git describe --abbrev=4 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-mod" ;;
esac
then
continue
#VN=$(echo "$VN" | sed -e 's/-/./g');
else
VN="$DEFAULT_VERSION"
fi
VN=$(expr "$VN" : v*'\(.*\)')
# Show the version to the user via stderr
echo >&2 "version: $VN"
# Parse the existing VERSION-FILE
if test -r $VF
then
VC=$(tail -1 $VF | sed -e 's/^__version__ = "\(.*\)"/\1/')
else
VC=unset
fi
# If version has changed, update VERSION-FILE
test "$VN" = "$VC" || {
sed 's/__version__ = .*/__version__ = "'$VN'"/g' $VF > tmp.py
mv tmp.py $VF
echo >&2 "($VF updated)"
}