From: Carl Worth <cworth@cworth.org>
To: git@vger.kernel.org
Subject: [PATCH] Munge ChangeLog-style commit messages, and grab author name and email.
Date: Fri, 10 Feb 2006 17:19:13 -0800 [thread overview]
Message-ID: <87slqqvgj2.wl%cworth@cworth.org> (raw)
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
next reply other threads:[~2006-02-11 1:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-11 1:19 Carl Worth [this message]
2006-02-11 5:39 ` [PATCH] Munge ChangeLog-style commit messages, and grab author name and email Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87slqqvgj2.wl%cworth@cworth.org \
--to=cworth@cworth.org \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox