-
Notifications
You must be signed in to change notification settings - Fork 1
/
svn-sync
executable file
·53 lines (42 loc) · 1.12 KB
/
svn-sync
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
#!/bin/bash
## Generate a preview and offer to execute any svn commands needed
## to sync this directory with the repository.
comments=$1
tmp=`mktemp /tmp/temp.XXXXXXX`
trap 'rm $tmp' EXIT;
svn status | awk '
/^\?/ {
system ("find " $2 " -printf \"svn add -N '\''%p'\''\n\"" )
next
}
/^M|^.M|^A|^D/ { print "#svn commit " $2 " (" $1 ")"; next }
/^!/ { print "svn delete '\''" $2 "'\''"; next }
// { print "#!Ignoring > " $0 }
' > $tmp
test -d .svn || exit 1
# Example: echo 'war/WEB-INF/classes.*' >> svn-sync-excludes
if test -f svn-sync-excludes
then
egrep -v -f svn-sync-excludes $tmp > ${tmp}2
mv ${tmp}2 $tmp
fi
if test -f svn-sync-excludes
then
egrep -f svn-sync-excludes $tmp > ${tmp}2
mv ${tmp}2 $tmp
fi
cat $tmp
#Exit if there are no commands to run
egrep --max-count=1 "^svn |^#svn commit " $tmp >/dev/null || exit 1
if test "${comments}z" != "z"
then
echo "svn commit --message '$comments'" | tee -a $tmp
else
echo "svn commit -message ''" | tee -a $tmp
fi
read -p "Proceed (y/n)? " yn
case $yn in
[Yy] ) ;; [Nn] ) exit 1 ;;
* ) echo "Please answer y or n"; exit 1 ;;
esac
sh $tmp