-
Notifications
You must be signed in to change notification settings - Fork 7
/
commit.sh
executable file
·60 lines (50 loc) · 1.36 KB
/
commit.sh
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
#!/bin/sh
#---
# Commit script for SVN.
#
# It automatically adds/removes new/missing files (use svn:ignore for
# files you don't want to include).
#
# Commits also changes done to the repositories designed as externals.
#
# Reuses svn-commit.tmp files left from uncommitted messages.
#---
externals=$(svn propget svn:externals | sed 's/.* //')
echo "Adding unversioned files"
echo "Note: to skip unwanted files add them to: svn propedit svn:ignore ."
svn add $(svn st | sed -n 's/^? *\(.*\)/\1/p') 2>/dev/null || true
echo "Delete missing files"
svn rm $(svn st | sed -n 's/^! *\(.*\)/\1/p') 2>/dev/null || true
svn st -u | grep "*" && {
echo "Changes in the remote repository found! Updating before doing the commit."
svn update
}
do_commit() {
( cd $1
# Reuse tmp commit message from last failed commit
if [ -f "svn-commit.tmp" ]
then
echo "---- Recommiting on: $(date)" >> svn-commit.tmp
svn status >> svn-commit.tmp
${EDITOR:-nano} svn-commit.tmp
ARGS="$ARGS -F svn-commit.tmp"
message=$(cat svn-commit.tmp | awk '/--.*--$/ {exit}; {print}')
if [ -z "$message" ]
then
echo "Empty message, abort commit? (Yn)"
read yn -sn 1
[ "$yn" != "n" ] && return
fi
fi
echo "Committing"
svn commit $ARGS
if [ "$?" -eq 0 ]
then
rm -fv svn-commit*.tmp
fi
)
}
for repo in . $externals
do
do_commit $repo
done