forked from dosemu2/dosemu2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getversion
executable file
·54 lines (50 loc) · 1.02 KB
/
getversion
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
#!/bin/sh
if git describe >/dev/null 2>&1 ; then
USE_GIT=1
else
USE_GIT=0
fi
if [ "$USE_GIT" = "1" ]; then
# need -n 1 for merge commits
DATE=`git log HEAD^..HEAD -n 1 --format=%cd --date=short`
REV=`git rev-list HEAD ^dosemu-1.5.0 --count`
else
DATE=`date -r VERSION +%F`
REV=`tail -n 1 VERSION`
fi
if test "$1" = "-r"; then
shift
if [ -n "$1" ]; then
REV=`git rev-list $1 ^dosemu-1.5.0 --count`
fi
echo "$REV"
exit 0
fi
if test "$1" = "-d"; then
echo "$DATE"
else
if [ "$USE_GIT" = "1" ]; then
DATE=`echo "$DATE" | sed -e 's/-//g'`
s=`git describe --tags --match '*2.*' HEAD 2>/dev/null | sed -e "s/-\([^-]\+-g\)/-$DATE-\1/"`
fi
v1=`head -n 1 VERSION`
if test -z "$s"; then
s=$v1
else
v=`echo $s | cut -d - -f 1`
fi
if test "$1" = "-s"; then
if test -n "$v"; then
echo "$v"
else
echo "$v1"
fi
exit 0
fi
if [ -n "$v" -a "$v" != "$v1" ]; then
echo "Update VERSION $v1 -> $v" >&2
echo $v > VERSION
echo "$REV" >> VERSION
fi
echo $s
fi