]> jfr.im git - irc/evilnet/znc.git/blob - version.sh
Merge pull request #1383 from Phansa/master
[irc/evilnet/znc.git] / version.sh
1 #!/bin/sh
2
3 # When changing this file, remember also about nightlies (make-tarball.sh)
4
5 # Get the path to the source directory
6 GIT_DIR=`dirname $0`
7
8 # Our argument should be the path to git
9 GIT="$1"
10 if [ "x$GIT" = "x" ]
11 then
12 EXTRA=""
13 else
14 GIT_HERE="${GIT}"
15 GIT="${GIT} --git-dir=${GIT_DIR}/.git"
16
17 # Figure out the information we need
18 LATEST_TAG=`${GIT} describe --abbrev=0 HEAD`
19 COMMITS_SINCE=`${GIT} log --pretty=oneline ${LATEST_TAG}..HEAD | wc -l`
20 # Explicitly make it a number: on openbsd wc -l returns " 42" instead of "42"
21 let COMMITS_SINCE=COMMITS_SINCE
22 SHORT_ID=`${GIT} rev-parse --short HEAD`
23
24 if [ "x$COMMITS_SINCE" = "x0" ]
25 then
26 if [ "x$LATEST_TAG" = "x" ]
27 then
28 if [ "x$SHORT_ID" = "x" ]
29 then
30 EXTRA=""
31 else
32 EXTRA="-git-${SHORT_ID}"
33 fi
34 else
35 # If this commit is tagged, don't print anything
36 # (the assumption here is: this is a release)
37 EXTRA=""
38 fi
39 else
40 EXTRA="-git-${COMMITS_SINCE}-${SHORT_ID}"
41 fi
42
43 if [ 1 = `cd ${GIT_DIR}; ${GIT_HERE} status --ignore-submodules=dirty --porcelain -- third_party/Csocket | wc -l` ]
44 then
45 # Makefile redirects all errors from this script into /dev/null, but this messages actually needs to be shown
46 # So put it to 3, and then Makefile redirects 3 to stderr
47 echo "Warning: Csocket submodule looks outdated. Run: git submodule update --init --recursive" 1>&3
48 EXTRA="${EXTRA}-frankenznc"
49 fi
50 fi
51
52 # Generate output file, if any
53 if [ "x$WRITE_OUTPUT" = "xyes" ]
54 then
55 echo '#include <znc/version.h>' > src/version.cpp
56 echo "const char* ZNC_VERSION_EXTRA = VERSION_EXTRA \"$EXTRA\";" >> src/version.cpp
57 fi
58
59 echo "$EXTRA"