forked from gtk-gnutella/gtk-gnutella
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit-revision
executable file
·88 lines (75 loc) · 1.96 KB
/
git-revision
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
#!/bin/sh
#
# $Id$
#
# Copyright (c) 2006, 2011, Raphael Manfredi
#
# Computes git current revision number, if possible, emitting it in
# the form of a #define for C perusal.
#
#----------------------------------------------------------------------
# This file is part of gtk-gnutella.
#
# gtk-gnutella 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; either version 2 of the License, or
# (at your option) any later version.
#
# gtk-gnutella 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. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with gtk-gnutella; if not, write to the Free Software
# Foundation, Inc.:
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#----------------------------------------------------------------------
#
LC_ALL=C
export LC_ALL
TOP="$1"
FILE="$2"
if [ "x$FILE" = x ]; then
FILE="&1"
oldrev=''
else
oldrev=`grep Revision "$FILE" 2>/dev/null | head -n1 | cut -d' ' -f4`
fi
. $TOP/scripts/git-version.sh >/dev/null
revnum="$VRev"
date="$DATE"
if grep GTA_BUILD_DATE "$FILE" >/dev/null 2>&1; then
olddate=`grep '#define GTA_BUILD_DATE' "$FILE" | \
sed -e 's/^.*"\(.*\)".*/\1/'`
else
olddate=$date
fi
if [ "x$revnum" = "x$oldrev" -a -f $FILE -a "x$olddate" = "x$date" ]; then
exit 0
fi
{
stamp=`date +"%Y-%m-%d %H:%M:%d %z"`
cat <<EOF
/*
* THIS FILE IS AUTOMATICALLY GENERATED -- DO NOT EDIT
*
* Generated by $0 on `date`
*/
EOF
if [ "x$revnum" = x ]; then
echo '/* No change since last git tag */'
else
XRev='$Revision'
cat <<EOF
#undef GTA_BUILD
#define GTA_BUILD "$XRev: $revnum \$"
EOF
if [ "x$DATE" != x ]; then
cat <<EOF
#undef GTA_BUILD_DATE
#define GTA_BUILD_DATE "$DATE"
EOF
fi
fi
} > "$FILE"