forked from amooma/GS3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get-version
executable file
·143 lines (124 loc) · 2.41 KB
/
get-version
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/bin/sh
# $Revision$
#if [ -z ${1} ]
#then
# TAGBASE="."
# cd `dirname $0`
#else
# TAGBASE=${1}
# cd ${TAGBASE} || exit 1
#fi
SVN_REPO_NAME="gemeinschaft"
TAGBASE="."
cd `dirname $0`
if [ -d .svn ]
then
PARTS=`LANG=C svn info ${TAGBASE} 2>>/dev/null | grep ^URL | awk '{print $2;}' | sed -e "s:^.*/${SVN_REPO_NAME}/::" | sed -e 's:/: :g'`
#echo "PARTS: ${PARTS}"
PART1=`echo "${PARTS}" | awk '{print $1;}'`
#echo "PART1: ${PART1}"
REV=`LANG=C svnversion -c ${TAGBASE} 2>>/dev/null | cut -d: -f2 | grep -o -E '[0-9]+' \
| sed -e 's:^[0-9]$:0\0:' \
| sed -e 's:^[0-9][0-9]$:0\0:' \
| sed -e 's:^[0-9][0-9][0-9]$:0\0:' \
| sed -e 's:^[0-9][0-9][0-9][0-9]$:0\0:' \
| sed -e 's:^[0-9][0-9][0-9][0-9][0-9]$:0\0:'`
#echo "REV: ${REV}"
if [ "${PART1}" = "trunk" ]
then
echo "trunk-r${REV}"
exit 0
fi
IS_TAG=0
IS_BRANCH=0
IS_TEAM_BRANCH=0
for PART in ${PARTS}
do
if [ ${IS_TAG} != 0 ]
then
RESULT="${PART}"
break
fi
if [ ${IS_BRANCH} != 0 ]
then
if [ -z ${RESULT} ]
then
RESULT="${PART}"
else
RESULT="${RESULT}-${PART}"
fi
break
fi
if [ ${IS_TEAM_BRANCH} != 0 ]
then
if [ -z ${RESULT} ]
then
RESULT="${PART}"
else
RESULT="${RESULT}-${PART}"
fi
continue
fi
if [ "${PART}" = "branches" ]
then
IS_BRANCH=1
RESULT="branch"
continue
fi
if [ "${PART}" = "tags" ]
then
IS_TAG=1
continue
fi
if [ "${PART}" = "team" ]
then
IS_TEAM_BRANCH=1
continue
fi
done
if [ ${IS_TAG} != 0 ]
then
echo "${RESULT}"
exit 0
else
if [ "${RESULT}" = "" ]
then
# neither in "tags" nor in "branches" nor in "team"
RESULT="other"
fi
if [ ${IS_TEAM_BRANCH} != 0 ]
then
echo "team-${RESULT}-r${REV}"
else
echo "${RESULT}-r${REV}"
fi
exit 0
fi
elif [ -d .git ]
then
# //FIXME!
if git branch --no-color | grep -i 'no branch' 1>>/dev/null 2>>/dev/null
then
# might be a tag
GIT_DESCR=`git describe --all --always`
echo "${GIT_DESCR}"
exit 0
fi
BRANCH=`git branch --no-color | grep '^ *[*] ' | grep -o -Ee '[a-zA-Z0-9\\-_.]+' | head -n 1`
if [ -z ${BRANCH} ]; then
BRANCH=unknown
fi
if [ "${BRANCH}" != "master" ]; then
BRANCH="branch-${BRANCH}"
fi
SHA=`git branch --no-color -v | grep '^ *[*] ' | awk '{print $3;}'`
if [ -z ${SHA} ]; then
SHA=unknown
fi
DATE=`date -u '+%Y%m%d'`
RESULT="${BRANCH}-${DATE}-${SHA}"
echo "${RESULT}"
exit 0
fi
echo "unknown"
exit 1