2005-10-16 [mones] 1.9.15cvs64
[claws.git] / commitHelper
1 #!/bin/bash
2 args=`echo $@`
3
4 head -n 16 configure.ac | grep VERSION= > /tmp/commitTool.tmp
5 source /tmp/commitTool.tmp
6 EXTRA_VERSION=`echo $EXTRA_VERSION | awk -F'.' '{for (i=1;i<NF;i++){printf $i"."};printf $NF+1}'`
7 nextsversion="${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}cvs${EXTRA_VERSION}"
8 nextextra="$EXTRA_VERSION"
9 nextextratype="head"
10 rm /tmp/commitTool.tmp
11
12 IFS='
13 '
14 filelist=`cvs status $@ configure.ac 2>/dev/null |grep ^File`
15
16 for file in $filelist; do
17         merge=`echo $file | grep Merge`
18         modif=`echo $file | grep Locally`
19         patch=`echo $file | grep Patch`
20         if [ "$patch" != "" ]; then
21                 echo $patch 
22                 echo You have to update first
23                 exit
24         fi;
25         if [ "$merge" != "" ]; then
26                 echo $merge 
27                 echo You have to update first
28                 exit
29         fi;
30         if [ "$modif" != "" ]; then
31                 echo $modif
32         fi;
33 done;
34 patchset="("
35 log=""
36 files=`cvs diff -uN $@ 2>/dev/null |grep ^Index`
37 name=`whoami`
38 #change if your login isn't your name
39 if [ "$name" == "claws" ]; then
40         name="paul";
41 fi;
42 if [ "$name" == "reboot" ]; then
43         name="christoph";
44 fi;
45 if [ "$name" == "leroyc" ]; then
46         name="colin";
47 fi;
48 if [ "$name" == "torte" ]; then
49         name="thorsten";
50 fi;
51 if [ "$name" == "dinh" ]; then
52         name="hoa";
53 fi;
54 if [ "$name" == "f" -o "$name" == "darkok" ]; then
55         name="darko";
56 fi;
57 if [ "$name" == "msp" ]; then
58         name="martin";
59 fi;
60 if [ "$name" == "devel" ]; then
61         name="mones";
62 fi;
63
64 log="`date --utc +%Y-%m-%d` [$name]\t$nextsversion\n\n"
65 for line in $files; do
66         file=`echo $line | cut -d' ' -f2`
67         dir=`dirname $file`
68         filename=`basename $file`
69         cvsfile="$dir/CVS/Entries"
70         version=`grep "\/$filename\/" $cvsfile | cut -d'/' -f3`
71         nextversion=`echo $version | awk -F'.' '{for (i=1;i<NF;i++){printf $i"."};printf $NF+1}'`
72         
73         log="$log\t* $file\n"
74         if [ "$version" != "0" ]; then
75         patchset="$patchset cvs diff -u -r $version -r $nextversion $file; "
76         else
77         patchset="$patchset diff -u /dev/null $file; "
78         fi
79 done;
80 patchset="$patchset ) > $nextsversion.patchset"
81
82 if [ "$EDITOR" == "" ]; then
83         EDITOR=vi
84 fi;
85
86
87 echo -e "#please complete the changelog entry below" > /tmp/logentry
88 echo -e -n $log >> /tmp/logentry
89
90 $EDITOR /tmp/logentry
91
92 echo "--8<----------"
93 grep -v "^#" /tmp/logentry > /tmp/log.tmp.$$ \
94 && mv /tmp/log.tmp.$$ /tmp/logentry
95 echo >> /tmp/logentry
96 cat /tmp/logentry
97
98 echo "--8<----------"
99 if [ -f ChangeLog-gtk2.claws ]; then
100         chlog="ChangeLog-gtk2.claws"
101 elif [ -f ChangeLog.claws ]; then
102         chlog="ChangeLog.claws"
103 else
104         chlog="ChangeLog"
105 fi
106 echo -n "Is it ok (write to $chlog and update configure.ac) [y/N]?"
107 read ans
108 if [ "$ans" == "y" ]; then
109         mv $chlog $chlog.old
110         cat /tmp/logentry > $chlog
111         cat $chlog.old >> $chlog
112         rm $chlog.old
113
114         cat configure.ac | sed "s/^EXTRA_VERSION=.*/EXTRA_VERSION=$nextextra/" > configure.ac.new \
115         && mv configure.ac.new configure.ac ;
116         
117         echo "$patchset" >> PATCHSETS
118
119         if [ "$args" != "" ]; then
120                 echo commiting $@ PATCHSETS $chlog configure.ac
121                 cvs commit -m "`cat /tmp/logentry`" $@ PATCHSETS $chlog configure.ac
122         else
123                 echo commiting recursively
124                 cvs commit -m "`cat /tmp/logentry` "
125         fi;
126         rm -f /tmp/logentry
127         wget -O /dev/null -o /dev/null http://www.colino.net/sylpheed-claws-gtk2/update.php3
128 fi