2005-03-31 [colin] 1.9.6cvs17
[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
20         if [ "$merge" != "" ]; then
21                 echo $merge
22                 echo You have to update first
23                 exit
24         fi;
25         if [ "$modif" != "" ]; then
26                 echo $modif
27         fi;
28 done;
29 patchset="("
30 log=""
31 files=`cvs diff -uN $@ 2>/dev/null |grep ^Index`
32 name=`whoami`
33 #change if your login isn't your name
34 if [ "$name" == "claws" ]; then
35         name="paul";
36 fi;
37 if [ "$name" == "reboot" ]; then
38         name="christoph";
39 fi;
40 if [ "$name" == "leroyc" ]; then
41         name="colin";
42 fi;
43 if [ "$name" == "torte" ]; then
44         name="thorsten";
45 fi;
46
47 log="`date --utc +%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
62 if [ "$EDITOR" == "" ]; then
63         EDITOR=vi
64 fi;
65
66
67 echo -e "#please complete the changelog entry below" > /tmp/logentry
68 echo -e -n $log >> /tmp/logentry
69
70 $EDITOR /tmp/logentry
71
72 echo "--8<----------"
73 grep -v "^#" /tmp/logentry > /tmp/log.tmp.$$ \
74 && mv /tmp/log.tmp.$$ /tmp/logentry
75 echo >> /tmp/logentry
76 cat /tmp/logentry
77
78 echo "--8<----------"
79 if [ -f ChangeLog-gtk2.claws ]; then
80         chlog="ChangeLog-gtk2.claws"
81 elif [ -f ChangeLog.claws ]; then
82         chlog="ChangeLog.claws"
83 else
84         chlog="ChangeLog"
85 fi
86 echo -n "Is it ok (write to $chlog and update configure.ac) [y/N]?"
87 read ans
88 if [ "$ans" == "y" ]; then
89         mv $chlog $chlog.old
90         cat /tmp/logentry > $chlog
91         cat $chlog.old >> $chlog
92         rm $chlog.old
93
94         cat configure.ac | sed "s/^EXTRA_VERSION=.*/EXTRA_VERSION=$nextextra/" > configure.ac.new \
95         && mv configure.ac.new configure.ac ;
96         
97         echo "$patchset" >> PATCHSETS
98
99         if [ "$args" != "" ]; then
100                 echo commiting $@ PATCHSETS $chlog configure.ac
101                 cvs commit -m "`cat /tmp/logentry`" $@ PATCHSETS $chlog configure.ac
102         else
103                 echo commiting recursively
104                 cvs commit -m "`cat /tmp/logentry` "
105         fi;
106         rm -f /tmp/logentry
107 fi