-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsvnrev
executable file
·36 lines (28 loc) · 1013 Bytes
/
svnrev
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
#!/bin/bash
# determine head revision number of svn repository
# prints "r###" if no files are different, else prints "r###+"
# if svn is not found, prints the empty string
# if svn client is not in path, print a blank line and exit
# note the "2>/dev/null" before the command to suppress stderr
if [ "_$(2>/dev/null which svn)" == "_" ] ; then
echo
# echo "no svn!"
exit
fi
# Note: need to be in root of checked out files for this to work!
# This assumes that changes outside the checked out directory are
# irrelevant to what has been checked out.
# get head revision of checked out files
REVISION=$(svn info -r 'HEAD' | grep Revision | grep -o '[0-9]\+')
# count changed files
CHANGED=$(svn diff | grep ^Index | wc -l | grep -o '[0-9]\+')
#echo "revison = '${REVISION}'"
#echo "changed = '${CHANGED}'"
# print main revision
echo -n "r${REVISION}"
# if files were changed, print a "+"
if [ ! "_${CHANGED}" == "_" ] && [ ! "_${CHANGED}" == "_0" ] ; then
echo -n "+"
fi
# print a final newline
echo