2007-09-16 [colin] 3.0.0cvs16
[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 ]; then
41                 echo See possible reason below:
42                 cat $tmpfile
43         fi
44         exit
45 fi
46 rm -f $tmpfile
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" == "leroyc" ]; then
53         name="colin";
54 fi;
55 if [ "$name" == "torte" ]; then
56         name="thorsten";
57 fi;
58 if [ "$name" == "dinh" ]; then
59         name="hoa";
60 fi;
61 if [ "$name" == "f" -o "$name" == "darkok" ]; then
62         name="darko";
63 fi;
64 if [ "$name" == "msp" ]; then
65         name="martin";
66 fi;
67 if [ "$name" == "devel" ]; then
68         name="mones";
69 fi;
70 if [ "$name" == "hb" ]; then
71         name="holger";
72 fi;
73
74 log="`date --utc +%Y-%m-%d` [$name]\t$nextsversion\n\n"
75 for line in $files; do
76         file=`echo $line | cut -d' ' -f2`
77         dir=`dirname $file`
78         filename=`basename $file`
79         cvsfile="$dir/CVS/Entries"
80         version=`grep "\/$filename\/" $cvsfile | cut -d'/' -f3`
81         nextversion=`echo $version | awk -F'.' '{for (i=1;i<NF;i++){printf $i"."};printf $NF+1}'`
82         
83         log="$log\t* $file\n"
84         if [ "$version" != "0" ]; then
85                 patchset="$patchset cvs diff -u -r $version -r $nextversion $file; "
86         else
87                 patchset="$patchset diff -u /dev/null $file; "
88         fi
89 done;
90 patchset="$patchset ) > $nextsversion.patchset"
91
92 if [ "$CVSEDITOR" == "" ]; then
93         if [ "$EDITOR" == "" ]; then
94                 if [ "$VISUAL" != "" ]; then
95                         EDITOR=$VISUAL
96                 else
97                         EDITOR=vi
98                 fi;
99         fi;
100 else
101         EDITOR=$CVSEDITOR
102 fi;
103
104 echo -e "#please complete the changelog entry below" > /tmp/logentry.$$
105 echo -e -n $log >> /tmp/logentry.$$
106
107 $EDITOR /tmp/logentry.$$
108
109 echo "--8<----------"
110 grep -v "^#" /tmp/logentry.$$ > /tmp/log.tmp.$$ \
111 && mv /tmp/log.tmp.$$ /tmp/logentry.$$
112 echo >> /tmp/logentry.$$
113 cat /tmp/logentry.$$
114
115 chlog="ChangeLog"
116
117 echo "--8<----------"
118 echo -n "Is it ok (write to $chlog and update configure.ac) [y/N]?"
119 read ans
120 if [ "$ans" == "y" ]; then
121         mv $chlog $chlog.old
122         cat /tmp/logentry.$$ > $chlog
123         cat $chlog.old >> $chlog
124         rm $chlog.old
125
126         cat configure.ac | sed "s/^EXTRA_VERSION=.*/EXTRA_VERSION=$nextextra/" > configure.ac.new \
127         && mv configure.ac.new configure.ac ;
128         
129         echo "$patchset" >> PATCHSETS
130
131         if [ "$args" != "" ]; then
132                 echo commiting $@ PATCHSETS $chlog configure.ac
133                 cvs commit -m "`cat /tmp/logentry.$$`" $@ PATCHSETS $chlog configure.ac
134         else
135                 echo commiting recursively
136                 cvs commit -m "`cat /tmp/logentry.$$` "
137         fi;
138         rm -f /tmp/logentry.$$
139         wget -O /dev/null -o /dev/null http://www.colino.net/sylpheed-claws/update.php3
140 fi