2bc0cb39d86dd3cbf7a51b8bd855626e6af58f72
[claws.git] / commitHelper
1 #!/bin/sh
2 head -16 configure.ac | grep VERSION= > /tmp/commitTool.tmp
3 source /tmp/commitTool.tmp
4 if [ -z "$EXTRA_GTK2_VERSION" ]; then
5         EXTRA_VERSION=`echo $EXTRA_VERSION | awk -F'.' '{for (i=1;i<NF;i++){printf $i"."};printf $NF+1}'`
6         nextsversion="${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}cvs${EXTRA_VERSION}"
7         nextextra="$EXTRA_VERSION"
8         nextextratype="head"
9 else
10         EXTRA_GTK2_VERSION=`echo $EXTRA_GTK2_VERSION | awk -F'.' '{for (i=1;i<NF;i++){printf $i"."};printf $NF+1}'`
11         nextsversion="${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}cvs${EXTRA_VERSION}${EXTRA_GTK2_VERSION}"
12         nextextra="$EXTRA_GTK2_VERSION"
13         nextextratype="gtk2"
14 fi
15 rm /tmp/commitTool.tmp
16
17 IFS='
18 '
19 filelist=`cvs status $@ 2>/dev/null |grep ^File`
20
21 for file in $filelist; do
22         merge=`echo $file | grep Merge`
23         modif=`echo $file | grep Locally`
24
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 -u $@ 2>/dev/null |grep ^Index`
37 echo "--8<----------"
38 name=`whoami`
39 #change if your login isn't your name
40 if [ "$name" == "claws" ]; then
41         name="paul";
42 fi;
43 if [ "$name" == "reboot" ]; then
44         name="christoph";
45 fi;
46
47 log="`date +%Y-%m-%d` [$name]\t$nextsversion\n\n"
48 for line in $files; do
49         file=`echo $line | cut -d' ' -f2`
50         dir=`dirname $file`
51         filename=`basename $file`
52         cvsfile="$dir/CVS/Entries"
53         version=`grep "\/$filename\/" $cvsfile | cut -d'/' -f3`
54         nextversion=`echo $version | awk -F'.' '{for (i=1;i<NF;i++){printf $i"."};printf $NF+1}'`
55         
56         log="$log\t* $file\n"
57         patchset="$patchset cvs diff -u -r $version -r $nextversion $file;\
58 "
59 done;
60 patchset="$patchset ) > $nextsversion.patchset"
61 log="$log\n"
62 echo -e -n $log
63 echo "--8<----------"
64 if [ -f ChangeLog-gtk2.claws ]; then
65         chlog="ChangeLog-gtk2.claws"
66 elif [ -f ChangeLog.claws ]; then
67         chlog="ChangeLog.claws"
68 else
69         chlog="ChangeLog"
70 fi
71 echo -n "Is it ok (write to $chlog and update configure.ac) [y/N]?"
72 read ans
73 if [ "$ans" == "y" ]; then
74         mv $chlog $chlog.old
75         echo -e -n $log > $chlog
76         cat $chlog.old >> $chlog
77         rm $chlog.old
78
79         if [ "$nextextratype" == "head" ]; then
80                 cat configure.ac | sed "s/^EXTRA_VERSION=.*/EXTRA_VERSION=$nextextra/" > configure.ac.new \
81                 && mv configure.ac.new configure.ac ;
82         else
83                 cat configure.ac | sed "s/^EXTRA_GTK2_VERSION=.*/EXTRA_GTK2_VERSION=$nextextra/" > configure.ac.new \
84                 && mv configure.ac.new configure.ac ;
85         fi;
86         
87         echo "$patchset" >> PATCHSETS
88         echo "editing $chlog ..."
89         if [ "$EDITOR" == "" ]; then
90                 EDITOR=vi
91         fi;
92         $EDITOR $chlog 
93         if [ "$@" != "" ]; then
94                 echo running cvs commit $@ PATCHSETS $chlog configure.ac
95                 cvs commit $@ PATCHSETS $chlog configure.ac
96         else
97                 echo running cvs commit
98                 cvs commit
99         fi;
100 fi