-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommitHelper
executable file
·152 lines (138 loc) · 3.5 KB
/
commitHelper
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
#!/bin/bash
args=`echo $@`
tmpfile=${0##*/}.tmp
head -n 16 configure.ac | grep -E "^[A-Z_]*VERSION=" > $tmpfile
source $tmpfile
EXTRA_VERSION=`echo $EXTRA_VERSION | awk -F'.' '{for (i=1;i<NF;i++){printf $i"."};printf $NF+1}'`
if test \( $EXTRA_VERSION -eq 0 \); then
if test \( $MICRO_VERSION -eq 0 \); then
VERSION=${MAJOR_VERSION}.${MINOR_VERSION}
else
VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}
fi
else
if test \( $MICRO_VERSION -eq 0 \); then
VERSION=${MAJOR_VERSION}.${MINOR_VERSION}cvs${EXTRA_VERSION}
else
VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}cvs${EXTRA_VERSION}
fi
fi
nextsversion="${VERSION}"
nextextra="$EXTRA_VERSION"
nextextratype="head"
rm -f $tmpfile
IFS='
'
filelist=`cvs status $@ configure.ac 2>/dev/null |grep ^File`
for file in $filelist; do
merge=`echo $file | grep Merge`
modif=`echo $file | grep Locally`
patch=`echo $file | grep Patch`
if [ "$patch" != "" ]; then
echo $patch
echo You have to update first
exit
fi;
if [ "$merge" != "" ]; then
echo $merge
echo You have to update first
exit
fi;
if [ "$modif" != "" ]; then
echo $modif
fi;
done;
patchset="("
log=""
files=`cvs diff -uN $@ 2>$tmpfile |grep ^Index`
if [ "$files" == "" ]; then
echo Nothing to commit\!
if [ -s $tmpfile ]; then
echo See possible reason below:
cat $tmpfile
fi
exit
fi
rm -f $tmpfile
name=`whoami`
#change if your login isn't your name
if [ "$name" == "claws" ]; then
name="paul";
fi;
if [ "$name" == "leroyc" ]; then
name="colin";
fi;
if [ "$name" == "torte" ]; then
name="thorsten";
fi;
if [ "$name" == "dinh" ]; then
name="hoa";
fi;
if [ "$name" == "f" -o "$name" == "darkok" ]; then
name="darko";
fi;
if [ "$name" == "msp" ]; then
name="martin";
fi;
if [ "$name" == "devel" ]; then
name="mones";
fi;
if [ "$name" == "hb" ]; then
name="holger";
fi;
log="`date --utc +%Y-%m-%d` [$name]\t$nextsversion\n\n"
for line in $files; do
file=`echo $line | cut -d' ' -f2`
dir=`dirname $file`
filename=`basename $file`
cvsfile="$dir/CVS/Entries"
version=`grep "\/$filename\/" $cvsfile | cut -d'/' -f3`
nextversion=`echo $version | awk -F'.' '{for (i=1;i<NF;i++){printf $i"."};printf $NF+1}'`
log="$log\t* $file\n"
if [ "$version" != "0" ]; then
patchset="$patchset cvs diff -u -r $version -r $nextversion $file; "
else
patchset="$patchset diff -u /dev/null $file; "
fi
done;
patchset="$patchset ) > $nextsversion.patchset"
if [ "$CVSEDITOR" == "" ]; then
if [ "$EDITOR" == "" ]; then
if [ "$VISUAL" != "" ]; then
EDITOR=$VISUAL
else
EDITOR=vi
fi;
fi;
else
EDITOR=$CVSEDITOR
fi;
echo -e "#please complete the changelog entry below" > /tmp/logentry.$$
echo -e -n $log >> /tmp/logentry.$$
$EDITOR /tmp/logentry.$$
echo "--8<----------"
grep -v "^#" /tmp/logentry.$$ > /tmp/log.tmp.$$ \
&& mv /tmp/log.tmp.$$ /tmp/logentry.$$
echo >> /tmp/logentry.$$
cat /tmp/logentry.$$
chlog="ChangeLog"
echo "--8<----------"
echo -n "Is it ok (write to $chlog and update configure.ac) [y/N]?"
read ans
if [ "$ans" == "y" ]; then
mv $chlog $chlog.old
cat /tmp/logentry.$$ > $chlog
cat $chlog.old >> $chlog
rm $chlog.old
cat configure.ac | sed "s/^EXTRA_VERSION=.*/EXTRA_VERSION=$nextextra/" > configure.ac.new \
&& mv configure.ac.new configure.ac ;
echo "$patchset" >> PATCHSETS
if [ "$args" != "" ]; then
echo commiting $@ PATCHSETS $chlog configure.ac
cvs commit -m "`cat /tmp/logentry.$$`" $@ PATCHSETS $chlog configure.ac
else
echo commiting recursively
cvs commit -m "`cat /tmp/logentry.$$` "
fi;
rm -f /tmp/logentry.$$
fi