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