bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/2] gitlog-to-changelog: support multi-author commits.


From: Gary V. Vaughan
Subject: [PATCH 1/2] gitlog-to-changelog: support multi-author commits.
Date: Tue, 1 Nov 2011 19:15:45 +0700

More generally useful gnulib-local goodness from my Libtool `next' branch:

I'm sure this is far from idiomatic Perl, but I'd very much like for this
patch or something similar to be pushed so that FSF projects have a means
to correctly track multiple patch authors with a generated ChangeLog file.

The idea is to add bare 'Co-authored-by: ' lines to the git log message,
which gitlog-to-changelog adds to the ChangeLog output in the usual format.
Libtool at least, and I believe other FSF projects have the concept of a
main author (the one on the date line) and additional authors (following)
which gels well with keeping the coauthors in a separate array, and only
suppressing consecutive headers blocks (date-line + coauthors) when the
main author, date, and co-authors all match.  That is, if the same group
of people apply consecutive patches on the same day, but with a different
"main author" each time, then a full header block is output each time.

Okay to push?

The FSF cares about keeping track of all authors of patches to its
projects, but Git doesn't provide obvious support for multi-author
changesets. Consensus seems to be forming around the use of extra
Signed-off-by inspired lines in the log message formatted as
`Co-authored-by: A U Thor <address@hidden>' for round-tripping
multi-author commits between version control systems.
* gitlog-to-changelog: Extract `Co-authored-by:' lines from the git
log message and output in standard ChangeLog multi-author format.
Reported by Peter Rosin <address@hidden>

---
 ChangeLog                     |   13 +++++++++++++
 build-aux/gitlog-to-changelog |   23 +++++++++++++++++------
 2 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 097de6c..f370be6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2011-11-01  Gary V. Vaughan  <address@hidden>
+
+       gitlog-to-changelog: support multi-author commits.
+       The FSF cares about keeping track of all authors of patches to its
+       projects, but Git doesn't provide obvious support for multi-author
+       changesets. Consensus seems to be forming around the use of extra
+       Signed-off-by inspired lines in the log message formatted as
+       `Co-authored-by: A U Thor <address@hidden>' for round-tripping
+       multi-author commits between version control systems.
+       * gitlog-to-changelog: Extract `Co-authored-by:' lines from the git
+       log message and output in standard ChangeLog multi-author format.
+       Reported by Peter Rosin <address@hidden>
+
 2011-11-01  Bruno Haible  <address@hidden>
 
        New module 'fchownat', split off from module 'openat'.
diff --git a/build-aux/gitlog-to-changelog b/build-aux/gitlog-to-changelog
index c776313..67d36af 100755
--- a/build-aux/gitlog-to-changelog
+++ b/build-aux/gitlog-to-changelog
@@ -3,7 +3,7 @@ eval '(exit $?0)' && eval 'exec perl -wS "$0" ${1+"$@"}'
     if 0;
 # Convert git log output to ChangeLog format.
 
-my $VERSION = '2011-10-31 16:06'; # UTC
+my $VERSION = '2011-11-01 11:50'; # UTC
 # The definition above must lie within the first 8 lines in order
 # for the Emacs time-stamp write hook (at end) to update it.
 # If you change this file with Emacs, please let the write hook
@@ -124,6 +124,7 @@ sub quoted_cmd(@)
             . "(Is your Git too old?  Version 1.5.1 or later is required.)\n");
 
   my $prev_date_line = '';
+  my @prev_coauthors = ();
   while (1)
     {
       defined (my $in = <PIPE>)
@@ -146,18 +147,28 @@ sub quoted_cmd(@)
           . "(expected date/author/email):\n$author_line\n";
 
       my $date_line = sprintf "%s  $2\n", strftime ("%F", localtime ($1));
-      # If this line would be the same as the previous date/name/email
-      # line, then arrange not to print it.
-      if ($date_line ne $prev_date_line)
+
+      # Format 'Co-authored-by: A U Thor <address@hidden>' lines in
+      # standard multi-author ChangeLog format.
+      my @coauthors = grep /^Co-authored-by:.*>$/, @line;
+      s/^Co-authored-by:\s*([^<]+)\s+</\t    \1  </
+        for (@coauthors);
+
+      # If this header would be the same as the previous date/name/email/
+      # coauthors header, then arrange not to print it.
+      if ($date_line ne $prev_date_line or "@coauthors" ne "@prev_coauthors")
         {
           $prev_date_line eq ''
             or print "\n";
           print $date_line;
+          print join ("\n", @coauthors), "\n"
+            unless (@coauthors == 0);
         }
       $prev_date_line = $date_line;
+      @prev_coauthors = @coauthors;
 
-      # Omit "Signed-off-by..." lines.
-      @line = grep !/^Signed-off-by: .*>$/, @line;
+      # Omit "Co-authored-by..." and "Signed-off-by..." lines.
+      @line = grep !/^(Co-authored|Signed-off)-by: .*>$/, @line;
 
       # Remove leading and trailing blank lines.
       while ($line[0] =~ /^\s*$/) { shift @line; }
-- 
1.7.7.1

Cheers,
-- 
Gary V. Vaughan (gary AT gnu DOT org)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]