This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Bring Porting/checkAUTHORS.pl into the world of git.
authorCraig A. Berry <craigberry@mac.com>
Thu, 25 Mar 2010 17:55:16 +0000 (12:55 -0500)
committerJesse Vincent <jesse@bestpractical.com>
Sat, 27 Mar 2010 16:13:10 +0000 (12:13 -0400)
Now processes git log output rather than the Changes file.  E.g.,

% git log --pretty=fuller --name-status perl-5.10.0..HEAD \
? | perl Porting/checkAUTHORS.pl --rank --percentage -

Also, the meaning of --thanks-applied has changed; it now only counts
commits where the committer is not the author.

Porting/checkAUTHORS.pl

index 6b22fc6..4620c68 100644 (file)
@@ -2,7 +2,7 @@
 use strict;
 use Text::Wrap;
 $Text::Wrap::columns = 80;
-my ($committer, $patch, $log,$date);
+my ($committer, $patch, $author, $date);
 use Getopt::Long;
 
 my ($rank, $percentage, $cumulative, $reverse, $ta, @authors, %authors,
@@ -17,13 +17,14 @@ my $result = GetOptions ("rank" => \$rank,            # rank authors
 
 if (!$result or (($rank||0) + ($ta||0) + (@authors ? 1 : 0) != 1) or !@ARGV) {
   die <<"EOS";
-$0 --rank Changelogs                        # rank authors by patches
-$0 --acknowledged <authors file> Changelogs # Display unacknowledged authors
-$0 --thanks-applied Changelogs            # ranks committers
+$0 --rank changes                           # rank authors by patches
+$0 --acknowledged <authors file> changes    # Display unacknowledged authors
+$0 --thanks-applied changes                 # ranks committers of others' patches
 $0 --percentage ...                         # show rankings as percentages
 $0 --cumulative ...                         # show rankings cumulatively
 $0 --reverse ...                            # show rankings in reverse
 Specify stdin as - if needs be. Remember that option names can be abbreviated.
+Generate changes with git log --pretty=fuller --name-status rev1..rev2
 EOS
 }
 
@@ -145,14 +146,16 @@ if (@authors) {
 
 my @lines = split(/^commit\s*/sm,join('',<>));
 for ( @lines) {
-    next if m/^$/;
+  next if m/^$/;
   next if m/^(\S*?)^Merge:/ism; # skip merge commits
-  if (m/^(.*?)^Author:\s*(.*?)^Date:\s*(.*?)^(.*)$/gism) {
+if (m/^(.*?)^Author:\s*(.*?)^AuthorDate:\s*(.*?)^Commit:\s*(.*?)^(.*)$/gism) {
     # new patch
-    ($patch, $committer, $date,$log) = ($1,$2,$3,$4);
+    ($patch, $author, $date, $committer) = ($1,$2,$3,$4);
+    chomp($author);
+    unless ($author) { die $_}
     chomp($committer);
     unless ($committer) { die $_}
-    &process ($committer, $patch, $log);
+    &process($committer, $patch, $author);
 } else { die "XXX $_ did not match";}
 }
 
@@ -206,22 +209,17 @@ sub display_ordered {
 }
 
 sub process {
-  my ($committer, $patch, $log) = @_;
+  my ($committer, $patch, $author) = @_;
+  return unless $author;
   return unless $committer;
-  my @authors = $log =~ /From:\s+.*?([^"\@ \t\n<>]+\@[^"\@ \t\n<>]+)/gm;
 
-  if (@authors) {
-    foreach my $addr (@authors) {
+  $author = _raw_address($author);
+  $patchers{$author}++;
 
-      $patchers{_raw_address($addr)}++;
-    }
-    # print "$patch: @authors\n";
-    $committers{_raw_address($committer)}++;
-  } else {
-      # print "$patch: $committer\n";
-    # Not entirely fair as this means that the maint pumpking scores for
-    # everything intergrated that wasn't a third party patch in blead
-    $patchers{_raw_address($committer)}++;
+  $committer = _raw_address($committer);
+  if ($committer ne $author) {
+    # separate commit credit only if committing someone else's patch
+    $committers{$committer}++;
   }
 }
 
@@ -232,6 +230,8 @@ sub _raw_address {
     $addr =~ s/^\s*(.*)\s*<\s*(.*?)\s*>.*$/$2/ ;
      $real_name = $1;
     }
+    $addr =~ s/\[mailto://;
+    $addr =~ s/\]//;
     $addr = lc $addr;
     $addr = $map{$addr} || $addr;
     $addr =~ s/\\100/@/g;  # Sometimes, there are encoded @ signs in the git log.
@@ -451,6 +451,7 @@ david\100kineticode.com                 david\100wheeler.com
 +                                       david\100wheeler.net
 dennis\100booking.com                   dennis\100camel.ams6.corp.booking.com
 dev-perl\100pimb.org                    knew-p5p\100pimb.org
++                                       lists-p5p\100pimb.org
 djberg86\100attbi.com                   djberg96\100attbi.com
 domo\100computer.org                    shouldbedomo\100mac.com
 +                                       domo\100slipper.ip.lu