* [PATCH] Munge ChangeLog-style commit messages, and grab author name and email.
@ 2006-02-11 1:19 Carl Worth
2006-02-11 5:39 ` Junio C Hamano
0 siblings, 1 reply; 2+ messages in thread
From: Carl Worth @ 2006-02-11 1:19 UTC (permalink / raw)
To: git
The cairo project has been using ChangeLog-style commit messages, such as:
2006-01-18 Carl Worth <cworth@cworth.org>
* src/cairo-pdf-surface.c: (cairo_pdf_surface_create_for_stream),
(cairo_pdf_surface_create): Fix compilation-breaking typo.
This patch recognizes that style and munges it up into:
Fix compilation-breaking typo.
which results in a much more useful headline within git.
It also grabs the name and email address from the first line and
commits with those as GIT_AUTHOR_NAME and GIT_AUTHOR_MAIL.
It would probably make sense to hide all this munging behind an
appropriate command-line parameter, but I'm offering this up as is in
case it's useful for anyone with similar commit messages.
Signed-off-by: Carl Worth <cworth@cworth.org>
Signed-off-by: Keith Packard <keithp@keithp.com>
---
git-cvsimport.perl | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 71 insertions(+), 0 deletions(-)
2f2002fe619c45cb1be1c0f063416ede242f3552
diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index 00fc3ba..6b63aa2 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -658,6 +658,12 @@ my $commit = sub {
}
}
+ # Look for name and email from ChangeLog-style commit message
+ if ($logmsg =~ /^\s*\d\d\d\d-\d\d-\d\d\s*(.*)\s*<(.*)>/) {
+ $author_name = $1;
+ $author_email = $2;
+ }
+
exec("env",
"GIT_AUTHOR_NAME=$author_name",
"GIT_AUTHOR_EMAIL=$author_email",
@@ -673,8 +679,73 @@ my $commit = sub {
# compatibility with git2cvs
substr($logmsg,32767) = "" if length($logmsg) > 32767;
+
+ # We do a bunch of munging on the log message here,
+ # particularly for logs that are formatted in a ChangeLog
+ # style.
+
+ my $origlog = $logmsg;
+
+ # Kill initial date/name stamp: YYYY-MM-DD First Last <email@example.com>
+
+ $logmsg =~ s|^\s*\d\d*-\d\d*-\d\d*\s*[^<\n]*<[^>\n]*>\s*$|* \n|mg;
+
+ # Strip out nickle version numbers
+ $logmsg =~ s|^(version )?2.\d\d*$||mg;
+
+ # Remove initial space for each line
+ $logmsg =~ s|^[ \t]+||mg;
+
+ # Collapse space sequences
+ $logmsg =~ s|[ \t]+| |g;
+
+ # Un-fold paragraphs
+ $logmsg =~ s|([^\n])\n([^*+\-\n])|$1 $2|g;
+
+ my @lines = split (/\n/, $logmsg);
+
+ $logmsg = "";
+
+ my $reviews = "";
+
+ foreach my $line (@lines) {
+ # Pull out any reviewed-by name
+ if ($line =~ /^reviewed by:\s*/i) {
+ if ($line !~ /<delete if not using/) {
+ $reviews = $reviews . "\n" . $line;
+ }
+ } else {
+ # find lines begining with '*'
+ if ($line =~ s/^\*\s\s*//) {
+ # strip off filenames
+ while ($line =~ s/^[^ :,]*([,:]| (?=\())\s*// ) {
+ }
+ # strip off function names
+ while ($line =~ s/^\([^)]*\)[,:]*\s*// ) {
+ }
+ }
+ $logmsg = $logmsg . $line . "\n";
+ }
+ }
+ $logmsg = $logmsg . $reviews;
+
+ # Trim initial newlines
+ $logmsg =~ s|^\n+||;
+
+ # Remove initial space for each line
+ $logmsg =~ s|^[ \t]+||mg;
+
+ # Collapse space sequences
+ $logmsg =~ s|[ \t]+| |g;
+
+ # collapse sequences of newlines
+ $logmsg =~ s/\n\n*/\n/g;
+
+ # Remove trailing whitespace
$logmsg =~ s/[\s\n]+\z//;
+# print "<<<< Original\n$origlog\n---- Rewritten\n$logmsg\n<<<<\n";
+
if (@skipped) {
$logmsg .= "\n\n\nSKIPPED:\n\t";
$logmsg .= join("\n\t", @skipped) . "\n";
--
1.1.6.g9da5
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] Munge ChangeLog-style commit messages, and grab author name and email.
2006-02-11 1:19 [PATCH] Munge ChangeLog-style commit messages, and grab author name and email Carl Worth
@ 2006-02-11 5:39 ` Junio C Hamano
0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2006-02-11 5:39 UTC (permalink / raw)
To: Carl Worth; +Cc: git
Carl Worth <cworth@cworth.org> writes:
> The cairo project has been using ChangeLog-style commit messages, such as:
>
> 2006-01-18 Carl Worth <cworth@cworth.org>
>
> * src/cairo-pdf-surface.c: (cairo_pdf_surface_create_for_stream),
> (cairo_pdf_surface_create): Fix compilation-breaking typo.
>
> This patch recognizes that style and munges it up into:
>
> Fix compilation-breaking typo.
>
> which results in a much more useful headline within git.
I welcome discussion on this patch, but as its in current shape,
it looks a bit too specific to one particular style.
I think the one you quoted above is the GNU official style which
is used in many projects. I suspect your patch would help
people converting other projects as well. Having said that, as
you said it yourself, it would make more sense to make a more
generalized log munging interface.
Even though there might be many different schools of style,
hopefully each project consistently sticks to one style. Log
messages out of SVN repository tend to have their own styles.
We could define a common command line option, say --log-filter,
that are available across importers. E.g.
git-cvsimport --log-filter=gnu-log-style
git-svnimport --log-filter=gnu-log-style
'gnu-log-style' would be the massager you have hardcoded in the
patch, but made into a traditional UNIXy filter. We could
create contrib/commit-filters directory in git.git repository
and ship collections of such log massagers.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-02-11 5:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-11 1:19 [PATCH] Munge ChangeLog-style commit messages, and grab author name and email Carl Worth
2006-02-11 5:39 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox