-i patch -> Patch
[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
52 log="`date --utc +%Y-%m-%d` [$name]\t$nextsversion\n\n"
53 for line in $files; do
54         file=`echo $line | cut -d' ' -f2`
55         dir=`dirname $file`
56         filename=`basename $file`
57         cvsfile="$dir/CVS/Entries"
58         version=`grep "\/$filename\/" $cvsfile | cut -d'/' -f3`
59         nextversion=`echo $version | awk -F'.' '{for (i=1;i<NF;i++){printf $i"."};printf $NF+1}'`
60         
61         log="$log\t* $file\n"
62         patchset="$patchset cvs diff -u -r $version -r $nextversion $file;\
63 "
64 done;
65 patchset="$patchset ) > $nextsversion.patchset"
66
67 if [ "$EDITOR" == "" ]; then
68         EDITOR=vi
69 fi;
70
71
72 echo -e "#please complete the changelog entry below" > /tmp/logentry
73 echo -e -n $log >> /tmp/logentry
74
75 $EDITOR /tmp/logentry
76
77 echo "--8<----------"
78 grep -v "^#" /tmp/logentry > /tmp/log.tmp.$$ \
79 && mv /tmp/log.tmp.$$ /tmp/logentry
80 echo >> /tmp/logentry
81 cat /tmp/logentry
82
83 echo "--8<----------"
84 if [ -f ChangeLog-gtk2.claws ]; then
85         chlog="ChangeLog-gtk2.claws"
86 elif [ -f ChangeLog.claws ]; then
87         chlog="ChangeLog.claws"
88 else
89         chlog="ChangeLog"
90 fi
91 echo -n "Is it ok (write to $chlog and update configure.ac) [y/N]?"
92 read ans
93 if [ "$ans" == "y" ]; then
94         mv $chlog $chlog.old
95         cat /tmp/logentry > $chlog
96         cat $chlog.old >> $chlog
97         rm $chlog.old
98
99         cat configure.ac | sed "s/^EXTRA_VERSION=.*/EXTRA_VERSION=$nextextra/" > configure.ac.new \
100         && mv configure.ac.new configure.ac ;
101         
102         echo "$patchset" >> PATCHSETS
103
104         if [ "$args" != "" ]; then
105                 echo commiting $@ PATCHSETS $chlog configure.ac
106                 cvs commit -m "`cat /tmp/logentry`" $@ PATCHSETS $chlog configure.ac
107         else
108                 echo commiting recursively
109                 cvs commit -m "`cat /tmp/logentry` "
110         fi;
111         rm -f /tmp/logentry
112 fi