forked from znc/znc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
version.sh
executable file
·48 lines (41 loc) · 1023 Bytes
/
version.sh
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
# When changing this file, remember also about nightlies
# Get the path to the source directory
GIT_DIR=`dirname $0`
# Our argument should be the path to git
GIT="$1"
if [ "x$GIT" = "x" ]
then
EXTRA=""
else
GIT="${GIT} --git-dir=${GIT_DIR}/.git"
# Figure out the information we need
LATEST_TAG=`${GIT} describe --abbrev=0 HEAD`
COMMITS_SINCE=`${GIT} log --format=oneline ${LATEST_TAG}..HEAD | wc -l`
SHORT_ID=`${GIT} rev-parse --short HEAD`
if [ "x$COMMITS_SINCE" = "x0" ]
then
if [ "x$LATEST_TAG" = "x" ]
then
if [ "x$SHORT_ID" = "x" ]
then
EXTRA=""
else
EXTRA="-git-${SHORT_ID}"
fi
else
# If this commit is tagged, don't print anything
# (the assumption here is: this is a release)
EXTRA=""
fi
else
EXTRA="-git-${COMMITS_SINCE}-${SHORT_ID}"
fi
fi
# Generate output file, if any
if [ "x$WRITE_OUTPUT" = "xyes" ]
then
echo '#include <znc/version.h>' > src/version.cpp
echo "const char* ZNC_VERSION_EXTRA = \"$EXTRA\";" >> src/version.cpp
fi
echo "$EXTRA"