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