File: update_revision.sh

package info (click to toggle)
codeblocks 16.01+dfsg-2.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 85,420 kB
  • ctags: 90,657
  • sloc: cpp: 665,947; ansic: 48,306; sh: 32,198; xml: 29,690; makefile: 6,054; asm: 3,827; python: 3,251; f90: 1,202; pascal: 839; yacc: 291; perl: 261; sed: 16
file content (71 lines) | stat: -rwxr-xr-x 2,415 bytes parent folder | download | duplicates (3)
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
#!/bin/sh

#
# This file is part of the Code::Blocks IDE and licensed under the GNU General Public License, version 3
# http://www.gnu.org/licenses/gpl-3.0.html
#
# $Revision: 10642 $
# $Id: update_revision.sh 10642 2016-01-16 12:51:18Z mortenmacfly $
# $HeadURL: http://svn.code.sf.net/p/codeblocks/code/branches/release-16.xx/update_revision.sh $
#


# make sure [git-]svn answers in english
export LC_ALL="C"

REV_FILE=./revision.m4

# let's import OLD_REV (if there)
if [ -f ./.last_revision ]; then
	. ./.last_revision
else
	OLD_REV=0
fi

if svn --xml info >/dev/null 2>&1; then
	echo "Using 'svn --xml info' to get the revision"
	REV=`svn --xml info | tr -d '\r\n' | sed -e 's/.*<commit.*revision="\([0-9]*\)".*<\/commit>.*/\1/'`
	LCD=`svn --xml info | tr -d '\r\n' | sed -e 's/.*<commit.*<date>\([0-9\-]*\)\T\([0-9\:]*\)\..*<\/date>.*<\/commit>.*/\1 \2/'`
elif svn --info >/dev/null 2>&1; then
	echo "Using 'svn info' to get the revision"
	REV=`svn info | grep "^Revision:" | cut -d" " -f2`
	LCD=`svn info | grep "^Last Changed Date:" | cut -d" " -f4,5`
#elif git svn --version >/dev/null 2>&1; then
#	echo "Using 'git svn info' to get the revision"
#	REV=`git svn info | grep "^Revision:" | cut -d" " -f2`
#	LCD=`git svn info | grep "^Last Changed Date:" | cut -d" " -f4,5`
elif git log --max-count=1 >/dev/null 2>&1; then
	echo "Using 'git log --graph' to get the revision"
	REV=`git log --graph | grep 'git-svn-id' | head -n 1 | grep -o -e "@\([0-9]*\)" | tr -d '@ '`
	LCD=`git log --date=iso --max-count=1 | grep -o -e "Date: \(.*\)" | cut -d ' ' -f 2- | sed 's/^ *//' | cut -f -2 -d ' '`
else
	REV=0
	LCD=""
fi

echo "Found revision: '${REV}' '${LCD}'"

if [ "x$REV" != "x$OLD_REV" -o ! -r $REV_FILE ]; then
	echo "m4_define([SVN_REV], $REV)" > $REV_FILE
	echo "m4_define([SVN_REVISION], 16.01svn$REV)" >> $REV_FILE
	echo "m4_define([SVN_DATE], $LCD)" >> $REV_FILE

	# Also change the revision number in debian/changelog for package versioning
	DCH=`which dch 2> /dev/null`
	if [ "x$DCH" != "x" ]; then
		if [ -x "$DCH" ]; then
			AKT_REV=`sed -e 's/.*svn\([0-9]*\).*/\1/' -e 'q' < debian/changelog`
			if [ $REV -gt $AKT_REV ]; then
				dch -v 16.01svn$REV "New svn revision"
			fi
		fi
	else
		mv debian/changelog debian/changelog.tmp
		sed "1 s/(16.01svn[^-)]*/(16.01svn$REV/" < debian/changelog.tmp > debian/changelog
		rm debian/changelog.tmp
	fi
fi

echo "OLD_REV=$REV" > ./.last_revision

exit 0