Gentoo Archives: gentoo-dev

From: Aron Griffis <agriffis@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] Proper commit messages
Date: Tue, 16 Aug 2005 01:37:08
Message-Id: 20050815140317.GA12239@olive.flatmonk
In Reply to: Re: [gentoo-dev] Proper commit messages by Markus Rothe
1 Markus Rothe wrote: [Tue Aug 09 2005, 07:36:18AM EDT]
2 > Personaly I find it a little bit annoying to write changes twise.
3 > One time in Changelog and one time in --commitmsg. How about using
4 > the commitmsg for Changelog as default, but if a Changelog entry
5 > already exists, then write nothing to Changelog.
6
7 A few others have posted their solutions to this problem. Perhaps
8 some people will find my solution useful, since it's a bit more
9 sophisticated. I've been using this for literally years now with no
10 modifications.
11
12 - handles using editor for echangelog
13 - fixes spacing before re-using the message for cvs commit
14 - post-runs eviewcvs (for the sake of pasting into bugs)
15
16 # echangelog and repoman combined
17 er() {
18 echangelog ${1:+"$*"} || return 1
19 rc
20 }
21
22 # repoman commit with the message from the ChangeLog
23 rc() {
24 declare msg
25
26 if [[ -n $* ]]; then
27 msg="$*"
28 echo "Using msg from command-line" >&2
29 else
30 msg=$(perl <ChangeLog -0777 -pe \
31 's/^.*?\n \d{2} \w{3} \d{4};.*?:\n//s || exit 1; # trim top
32 s/\n(?:\*| \d{2} \w{3} \d{4};).*//s; # trim bottom
33 s/^\s*//; s/\s*$//; s/^(?: |\t)//gm; # fix spacing
34 #/^ /m || s/\s+/ /g; # normalize spacing unless formatted
35 ')
36 if [[ $? != 0 || -z $msg ]]; then
37 echo "couldn't parse message from ChangeLog" >&2
38 return 1
39 fi
40 echo "Parsed msg from ChangeLog" >&2
41 fi
42
43 echo "----------" >&2
44 echo "$msg" >&2
45 echo "----------" >&2
46
47 repoman commit -m "$msg" || return 1
48
49 if [[ -x /usr/bin/eviewcvs ]]; then
50 local f entry=$(perl -00ne '/^ \d/ and print, last' ChangeLog)
51 entry=${entry%%:*}
52 entry=${entry##*>}
53 entry=${entry//,/ }
54 for f in $entry; do
55 [[ $f == -* ]] && continue
56 f=${f#+}
57 echo "$f"
58 done | xargs -n1 eviewcvs
59 fi
60 }
61
62 Regards,
63 Aron
64
65 --
66 Aron Griffis
67 Gentoo Linux Developer