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