forked from tkLayout/tkLayout
-
Notifications
You must be signed in to change notification settings - Fork 1
/
getRevisionDefine
executable file
·28 lines (25 loc) · 1006 Bytes
/
getRevisionDefine
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
#!/bin/sh
alias errecho='>&2 echo'
if [ -d '.git' ]; then
myVersion="`git rev-parse --abbrev-ref HEAD`-`git rev-list HEAD | wc -l`-`git rev-parse --short HEAD` on `git config --get remote.origin.url`"
# echo "-DREVISIONNUMBER=\"\\\"$myVersion\\\"\""
elif [ -d '.svn' ] ; then
if which svnversion >/dev/null; then
# svnversion exists
myVersion=`svnversion`
base_repo=`svn info | egrep '^URL' | sed -e 's/^URL: *//g' -e 's#.*/##g'`
serverName=`svn info | egrep ^Repository: | sed -e 's/^Repository: //g'`
if echo $myVersion | grep -qe '[0-9]' ; then
# There is a number in the version, so probably it makes sense
myVersion="${base_repo}/${myVersion} on $serverName"
# echo -DREVISIONNUMBER=\"${base_repo}/${myVersion}\"
else
myVersion="UNKNOWN"
fi
fi
else
errecho This repository is not under git or svn. Cannot get a version define
# echo "-DREVISIONNUMBER=\"UNKNOWN\""
myVersion="UNKNOWN"
fi
echo -DREVISIONNUMBER=\"\\\"$myVersion\\\"\"