You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Change: [Makefile] replace custom git-detection with 'findversion.sh' (#25)
'findversion.sh' is a script from the OpenTTD repository. This means
OpenGFX now acts the same as OpenTTD in terms of version, filename,
etc.
Makefile.vcs is now only used to know when to retrigger targets, and
no longer part of the source tarballs.
# OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
5
+
# OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
6
+
# See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
7
+
8
+
9
+
# Arguments given? Show help text.
10
+
if [ "$#"!="0" ];then
11
+
cat <<EOF
12
+
Usage: ./findversion.sh
13
+
Finds the current revision and if the code is modified.
14
+
15
+
Output: <VERSION>\t<ISODATE>\t<MODIFIED>\t<HASH>
16
+
VERSION
17
+
a string describing what version of the code the current checkout is
18
+
based on.
19
+
This also includes the commit date, an indication of whether the checkout
20
+
was modified and which branch was checked out. This value is not
21
+
guaranteed to be sortable, but is mainly meant for identifying the
22
+
revision and user display.
23
+
24
+
If no revision identifier could be found, this is left empty.
25
+
ISODATE
26
+
the commit date of the revision this checkout is based on.
27
+
The commit date may differ from the author date.
28
+
This can be used to decide upon the age of the source.
29
+
30
+
If no timestamp could be found, this is left empty.
31
+
MODIFIED
32
+
Whether (the src directory of) this checkout is modified or not. A
33
+
value of 0 means not modified, a value of 2 means it was modified.
34
+
35
+
A value of 1 means that the modified status is unknown, because this
36
+
is not an git checkout for example.
37
+
38
+
HASH
39
+
the git revision hash
40
+
41
+
By setting the AWK environment variable, a caller can determine which
42
+
version of "awk" is used. If nothing is set, this script defaults to
43
+
"awk".
44
+
EOF
45
+
exit 1;
46
+
fi
47
+
48
+
# Allow awk to be provided by the caller.
49
+
if [ -z"$AWK" ];then
50
+
AWK=awk
51
+
fi
52
+
53
+
# Find out some dirs
54
+
cd`dirname "$0"`
55
+
ROOT_DIR=`pwd`
56
+
57
+
# Determine if we are using a modified version
58
+
# Assume the dir is not modified
59
+
MODIFIED="0"
60
+
if [ -d"$ROOT_DIR/.git" ] || [ -f"$ROOT_DIR/.git" ];then
61
+
# We are a git checkout
62
+
# Refresh the index to make sure file stat info is in sync, then look for modifications
63
+
git update-index --refresh >/dev/null
64
+
if [ -n"`git diff-index HEAD`" ];then
65
+
MODIFIED="2"
66
+
fi
67
+
HASH=`LC_ALL=C git rev-parse --verify HEAD 2>/dev/null`
68
+
SHORTHASH=`echo ${HASH}| cut -c1-10`
69
+
ISODATE=`LC_ALL=C git show -s --pretty='format:%ci' HEAD |"$AWK"'{ gsub("-", "", $1); print $1 }'`
70
+
BRANCH="`git symbolic-ref -q HEAD 2>/dev/null | sed 's@.*/@@'`"
71
+
TAG="`git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null | sed 's@\^0$@@'`"
72
+
73
+
if [ "$MODIFIED"-eq"0" ];then
74
+
hashprefix="-g"
75
+
elif [ "$MODIFIED"-eq"2" ];then
76
+
hashprefix="-m"
77
+
else
78
+
hashprefix="-u"
79
+
fi
80
+
81
+
if [ -n"$TAG" ];then
82
+
VERSION="${TAG}"
83
+
ISTAG="1"
84
+
if [ -n"`echo \"${TAG}\"| grep \"^[0-9.]*$\"`" ];then
0 commit comments