-
Notifications
You must be signed in to change notification settings - Fork 3
/
commit.sh
executable file
·164 lines (159 loc) · 3.74 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#! /bin/bash -e
#
# replacement text for this commit
cat << EOF > commit.$$
Removed srcIP, and added covariance estimation routine and test.
EOF
# -----------------------------------------------------------------------
if [ "$1" == 'files' ]
then
echo "rm commit.[0-9]*"
rm commit.[0-9]*
#
echo "cp commit.sh commit.old"
cp commit.sh commit.old
#
echo "svn revert commit.sh"
svn revert commit.sh
#
sed -n -e '1,/^$/p' < commit.sh > commit.$$
svn status | sed -n -e '/^[ADMRC] /p' | \
sed -e 's/^[ADMR] [+ ]*//' -e 's/$/@/' | \
sort -u >> commit.$$
sed -n -e '/^EOF/,$p' < commit.sh >> commit.$$
#
echo "diff commit.sh commit.$$"
if diff commit.sh commit.$$
then
echo "commit.sh: exiting because commit.sh has not changed"
exit 1
fi
#
echo "mv commit.$$ commit.sh"
mv commit.$$ commit.sh
#
chmod +x commit.sh
exit 0
fi
# -----------------------------------------------------------------------
if [ "$1" != 'run' ]
then
cat << EOF
usage: ./commit.sh files
./commit.sh run
example/tridiag_solve_ok.m@
src/ckbs_tridiag_solve.m@
src/ckbs_tridiag_solve_b.m@
src/ckbs_tridiag_solve_mf.m@
EOF
# -----------------------------------------------------------------------
if [ "$1" == 'files' ]
then
echo "rm commit.[0-9]*"
rm commit.[0-9]*
#
echo "cp commit.sh commit.old"
cp commit.sh commit.old
#
echo "svn revert commit.sh"
svn revert commit.sh
#
sed -n -e '1,/^$/p' < commit.sh > commit.$$
svn status | sed -n -e '/^[ADMRC] /p' | \
sed -e 's/^[ADMR] [+ ]*//' -e 's/$/@/' | \
sort -u >> commit.$$
sed -n -e '/^EOF/,$p' < commit.sh >> commit.$$
#
echo "diff commit.sh commit.$$"
if diff commit.sh commit.$$
then
echo "commit.sh: exiting because commit.sh has not changed"
exit 1
fi
#
echo "mv commit.$$ commit.sh"
mv commit.$$ commit.sh
#
chmod +x commit.sh
exit 0
fi
# -----------------------------------------------------------------------
if [ "$1" != 'run' ]
then
cat << EOF
usage: ./commit.sh files
./commit.sh run
example/tridiag_inv_ok.m@
src/ckbs_tridiag_inv.m@
EOF
# -----------------------------------------------------------------------
if [ "$1" == 'files' ]
then
echo "rm commit.[0-9]*"
rm commit.[0-9]*
#
echo "cp commit.sh commit.old"
cp commit.sh commit.old
#
echo "svn revert commit.sh"
svn revert commit.sh
#
sed -n -e '1,/^$/p' < commit.sh > commit.$$
svn status | sed -n -e '/^[ADMRC] /p' | \
sed -e 's/^[ADMR] [+ ]*//' -e 's/$/@/' | \
sort -u >> commit.$$
sed -n -e '/^EOF/,$p' < commit.sh >> commit.$$
#
echo "diff commit.sh commit.$$"
if diff commit.sh commit.$$
then
echo "commit.sh: exiting because commit.sh has not changed"
exit 1
fi
#
echo "mv commit.$$ commit.sh"
mv commit.$$ commit.sh
#
chmod +x commit.sh
exit 0
fi
# -----------------------------------------------------------------------
if [ "$1" != 'run' ]
then
cat << EOF
usage: ./commit.sh files
./commit.sh run
The first from changes the list of files at the beginning of commit.sh
so that it all the files that have changed status.
You should then edit commit.sh by hand (as per the instrucgtion at the
beginning of commit.sh) before running the second form.
The second form actually commits the list of files (provided that you reply
y to the [y/n] prompt that commit.sh generates).
EOF
rm commit.$$
exit 0
fi
# -----------------------------------------------------------------------
list=`sed -e '/@/! d' -e 's/@.*//' commit.$$`
msg=`sed -e '/@ *$/d' -e 's|.*/\([^/]*@\)|\1|' -e 's|@|:|' commit.$$`
rm commit.$$
echo "svn commit -m \""
echo "$msg"
echo "\" \\"
echo "$list"
read -p "is this ok [y/n] ?" response
if [ "$response" != "y" ]
then
exit 1
fi
#
if ! svn commit -m "$msg" $list
then
echo "commit.sh: commit failed"
exit 1
fi
#
echo "mv commit.sh commit.old"
mv commit.sh commit.old
#
svn revert commit.sh