File: svn-revision

package info (click to toggle)
mailagent 1%3A3.1-106-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 3,184 kB
  • sloc: perl: 15,877; sh: 8,600; ansic: 2,756; makefile: 75
file content (70 lines) | stat: -rwxr-xr-x 1,413 bytes parent folder | download
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
#!/bin/sh

#
# $Id: svn-revision 12303 2006-11-11 08:11:46Z cbiere $
#
# Copyright (c) 2006, Raphael Manfredi
#
#  You may redistribute only under the terms of the Artistic Licence,
#  as specified in the README file that comes with the distribution.
#  You may reuse parts of this distribution only within the terms of
#  that same Artistic Licence; a copy of which may be found at the root
#  of the source tree for dist 4.0.
#
# Computes SVN current revision number, if possible, emitting it in
# the form of a #define for C perusal.
#
# On 2016-04-01, we switched to git so until we come up with a more elaborate
# scheme, the current version number is computed by counting the amount of
# commits made on the "master" branch.
#

LC_ALL=C
export LC_ALL

TOP="$1"
FILE="$2"
BRANCH="$3"

if [ -z "$BRANCH" ]; then
    BRANCH="master"
fi


if [ "x$FILE" = x ]; then
	FILE="&1"
	oldrev=''
else
	oldrev=`grep REVISION "$FILE" 2>/dev/null | head -n1 | cut -d' ' -f3`
fi

if test -d "$TOP/.git"; then
  revnum=`git log --oneline $BRANCH | wc -l`
else
  revnum="$oldrev" # keep as is
fi

if [ "x$revnum" = "x$oldrev" ]; 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.
 */

EOF

if [ "x$revnum" = x ]; then
	echo '/* Subversion information not available */'
else
	cat <<EOF
#define REVISION $revnum
EOF
fi

} > "$FILE"