This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade to CPAN-1.88_53.
[perl5.git] / Porting / checkAUTHORS.pl
1 #!/usr/bin/perl -w
2 use strict;
3 use Text::Wrap;
4 $Text::Wrap::columns = 80;
5 my ($committer, $patch, $log);
6 use Getopt::Long;
7
8 my ($rank, $percentage, $cumulative, $reverse, $ta, @authors, %authors,
9     %untraced, %patchers, %committers);
10 my $result = GetOptions ("rank" => \$rank,                  # rank authors
11                          "thanks-applied" => \$ta,          # ranks committers
12                          "acknowledged=s"   => \@authors ,  # authors files
13                          "percentage" => \$percentage,      # show as %age
14                          "cumulative" => \$cumulative,
15                          "reverse" => \$reverse,
16                         );
17
18 if (!$result or (($rank||0) + ($ta||0) + (@authors ? 1 : 0) != 1) or !@ARGV) {
19   die <<"EOS";
20 $0 --rank Changelogs                        # rank authors by patches
21 $0 --acknowledged <authors file> Changelogs # Display unacknowledged authors
22 $0 --thanks-applied Changelogs              # ranks committers
23 $0 --percentage ...                         # show rankings as percentages
24 $0 --cumulative ...                         # show rankings cumulatively
25 $0 --reverse ...                            # show rankings in reverse
26 Specify stdin as - if needs be. Remember that option names can be abbreviated.
27 EOS
28 }
29
30 my %map = reverse (
31                    # "Correct" => "Alias"
32                    adi => "enache\100rdslink.ro",
33                    alanbur => "alan.burlison\100sun.com",
34                    ams => "ams\100wiw.org",
35                    chip => "chip\100pobox.com",
36                    davem => "davem\100fdgroup.com",
37                    doughera => " doughera\100lafayette.edu",
38                    gbarr => "gbarr\100pobox.com",
39                    gsar => "gsar\100activestate.com",
40                    hv => "hv\100crypt.compulink.co.uk",
41                    jhi => "jhi\100iki.fi",
42                    merijn => "h.m.brand\100xs4all.nl",
43                    mhx => "mhx-perl\100gmx.net",
44                    nicholas => "nick\100unfortu.net",
45                    nick => "nick\100ing-simmons.net",
46                    pudge => "pudge\100pobox.com",
47                    rgs => "rgarciasuarez\100free.fr",
48                    sky => "sky\100nanisky.com", 
49                    steveh => "steve.hay\100uk.radan.com",
50                    stevep => "steve\100fisharerojo.org",
51                    gisle => "gisle\100activestate.com",
52                    "abigail\100abigail.nl"=> "abigail\100foad.org",
53                    "chromatic\100wgz.org" => "chromatic\100rmci.net",
54                    "slaven\100rezic.de" => "slaven.rezic\100berlin.de",
55                    "mjtg\100cam.ac.uk" => "mjtg\100cus.cam.ac.uk",
56                    "robin.barker\100npl.co.uk" => "rmb1\100cise.npl.co.uk",
57                    "paul.marquess\100btinternet.com"
58                    => "paul_marquess\100yahoo.co.uk",
59                    "wolfgang.laun\100chello.at" =>
60                    "wolfgang.laun\100alcatel.at",
61                    "t.jenness\100jach.hawaii.edu" => "timj\100jach.hawaii.edu",
62                    "abe\100ztreet.demon.nl" => "abeltje\100cpan.org",
63                    "nospam-abuse\100bloodgate.com" => "tels\100bloodgate.com",
64                    "jfriedl\100yahoo.com" => "jfriedl\100yahoo-inc.com",
65                    "japhy\100pobox.com" => "japhy\100pobox.org",
66                    "gellyfish\100gellyfish.com" => "jns\100gellyfish.com",
67                    "jcromie\100divsol.com" => "jcromie\100cpan.org",
68                    "demerphq\100gmail.com" => "demerphq\100hotmail.com",
69                    "rick\100consumercontact.com" => "rick\100bort.ca",
70                    "vkonovalov\100spb.lucent.com"
71                    => "vkonovalov\100peterstar.ru",
72                    "rjk\100linguist.dartmouth.edu"
73                    => "rjk\100linguist.thayer.dartmouth.edu",
74                    "domo\100computer.org" => "shouldbedomo\100mac.com",
75                    "kane\100dwim.org" => "kane\100xs4all.net",
76                    "allens\100cpan.org" => "easmith\100beatrice.rutgers.edu",
77                    "spoon\100cpan.org" => "spoon\100dellah.org",
78                    "ben_tilly\100operamail.com" => "btilly\100gmail.com",
79                    "mbarbon\100dsi.unive.it" => "mattia.barbon\100libero.it",
80                    "tassilo.parseval\100post.rwth-aachen.de" =>
81                    "tassilo.von.parseval\100rwth-aachen.de",
82                    "dcd\100tc.fluke.com" => "david.dyck\100fluke.com",
83                    "kroepke\100dolphin-services.de"
84                    => "kay\100dolphin-services.de",
85                    "sebastien\100aperghis.net" => "maddingue\100free.fr",
86                    "radu\100netsoft.ro" => "rgreab\100fx.ro",
87                    "rick\100consumercontact.com"
88                    => "rick.delaney\100rogers.com",
89                    "p5-authors\100crystalflame.net"
90                    => "perl\100crystalflame.net",
91                    "stef\100mongueurs.net" => "stef\100payrard.net",
92                    "kstar\100wolfetech.com" => "kstar\100cpan.org",
93                    "7k8lrvf02\100sneakemail.com" =>
94                    "kjx9zthh3001\100sneakemail.com",
95                    "mgjv\100comdyn.com.au" => "mgjv\100tradingpost.com.au",
96                    "thomas.dorner\100start.de" => "tdorner\100amadeus.net",
97                    "ajohnson\100nvidia.com" => "ajohnson\100wischip.com",
98                    "phil\100perkpartners.com" => "phil\100finchcomputer.com",
99                    "tom.horsley\100mail.ccur.com" => "tom.horsley\100ccur.com",
100                    "rootbeer\100teleport.com" => "rootbeer\100redcat.com",
101                    "cp\100onsitetech.com" => "publiustemp-p5p\100yahoo.com",
102                    "epeschko\100den-mdev1" => "esp5\100pge.com",
103                    "pimlott\100idiomtech.com" => "andrew\100pimlott.net",
104                    "fugazi\100zyx.net" => "larrysh\100cpan.org",
105                    "merijnb\100iloquent.nl" => "merijnb\100iloquent.com",
106                    "whatever\100davidnicol.com" => "davidnicol\100gmail.com",
107                    "rmgiroux\100acm.org" => "rmgiroux\100hotmail.com",
108                    "smcc\100mit.edu" => "smcc\100ocf.berkeley.edu",
109                    "schubiger\100cpan.org" => "steven\100accognoscere.org",
110                    "richard.foley\100ubsw.com"
111                    => "richard.foley\100t-online.de",
112                    "damian\100cs.monash.edu.au" => "damian\100conway.org",
113                    "gp\100familiehaase.de" => "gerrit\100familiehaase.de",
114                    "juerd\100cpan.org" => "juerd\100convolution.nl",
115                    "paul.green\100stratus.com"
116                    => "paul_greenvos\100vos.stratus.com",
117                    "alian\100cpan.org" => "alian\100alianwebserver.com",
118                    "david.dyck\100fluke.com" => "dcd\100tc.fluke.com",
119                    # Maybe we should special case this to get real names out?
120                    "perlbug\100perl.org" => "perlbug-followup\100perl.org",
121                   );
122
123 # Make sure these are all lower case.
124
125 $map{"autrijus\100egb.elixus.org"} = $map{"autrijus\100geb.elixus.org"}
126   = $map{"autrijus\100gmail.com"} = $map{"autrijus\100ossf.iis.sinica.edu.tw"}
127   = $map{"autrijus\100autrijus.org"} = "cpan\100audreyt.org";
128 $map{"ilya\100math.ohio-state.edu"} = $map{"ilya\100math.berkeley.edu"}
129   = $map{"ilya\100math.berkeley.edu"} = "nospam-abuse\100ilyaz.org";
130 $map{"philip.newton\100gmx.net"} = $map{"philip.newton\100datenrevision.de"}
131   = $map{"pnewton\100gmx.de"} = "pne\100cpan.org",
132 $map{"simon\100pembro4.pmb.ox.ac.uk"} = $map{"simon\100brecon.co.uk"}
133   = $map{"simon\100othersideofthe.earth.li"} = $map{"simon\100cozens.net"}
134   = $map{"simon\100netthink.co.uk"} = "simon\100simon-cozens.org";
135 $map{"spider\100web.zk3.dec.com"} = $map{"spider\100leggy.zk3.dec.com"}
136   = $map{"spider-perl\100orb.nashua.nh.us"}
137   = $map{"spider\100peano.zk3.dec.com"}
138   = "spider\100orb.nashua.nh.us";
139 $map{"andreas.koenig.gmwojprw\100franz.ak.mind.de"}
140   = $map{"a.koenig\100mind.de"} =  "andreas.koenig\100anima.de";
141 $map{"japhy\100perlmonk.org"} = $map{"japhy\100cpan.org"}
142   = "japhy\100pobox.com";
143 $map{"rmbarker\100cpan.org"} = "robin.barker\100npl.co.uk";
144 $map{"yves.orton\100de.mci.com"} = $map{"yves.orton\100mciworldcom.de"}
145   = "demerphq\100gmail.com";
146 $map{"jim.cromie\100gmail.com"} = "jcromie\100divsol.com";
147 $map{"perl_dummy\100bloodgate.com"} = "nospam-abuse\100bloodgate.com";
148 $map{"paul.marquess\100ntlworld.com"} = "paul.marquess\100btinternet.com";
149 $map{"konovalo\100mail.wplus.net"} = $map{"vadim\100vkonovalov.ru"}
150   = "vkonovalov\100spb.lucent.com";
151 $map{"kane\100cpan.org"} = "kane\100dwim.org";
152 $map{"rs\100crystalflame.net"} = "p5-authors\100crystalflame.net";
153 $map{"(srezic\100iconmobile.com)"} = "slaven\100rezic.de";
154 $map{"perl\100dellah.anu.edu.au"} = "spoon\100cpan.org";
155 $map{"rjk-perl-p5p\100tamias.net"} = "rjk\100linguist.dartmouth.edu";
156 $map{"sts\100accognoscere.org"} = "schubiger\100cpan.org";
157 $map{"s.payrard\100wanadoo.fr"} = "stef\100mongueurs.net";
158 $map{"richard.foley\100ubs.com"} = "richard.foley\100ubsw.com";
159 # I assume that Ton Hopsel's lack of e-mail address in AUTHORS is deliberate
160 $map{"me-02\100ton.iguana.be"} = $map{"perl-5.8.0\100ton.iguana.be"}
161   = $map{"perl5-porters\100ton.iguana.be"} = "!";
162 # No real name for these address
163 $map{$_} = "?" foreach ("grommel\100sears.com", "pxm\100nubz.org",
164                         "padre\100elte.hu", "jdhedden\100" . "1979.usna.com",
165                         "nothingmuch\100woobling.org", "bob\100starlabs.net",
166                         "bbucklan\100jpl-devvax.jpl.nasa.gov",
167                         "bilbo\100ua.fm", "mats\100sm5sxl.net",
168                         "chris\100ex-parrot.com", 
169                         "kaminsky\100math.huji.ac.il",
170                         "bonefish\100cs.tu-berlin.de",
171                         "bstrand\100switchmanagement.com",
172                         "glasser\100tang-eleven-seventy-nine.mit.edu",
173                         "raf\100tradingpost.com.au", "erik\100cs.uni-jena.de",
174                         "jms\100mathras.comcast.net", "kvr\100centrum.cz",
175                         "perlbug\100veggiechinese.net",
176                         "scott\100perlcode.org",
177                        );
178 # We don't have an e-mail address for Beau Cox
179 $map{"beau\100beaucox.com"} = "?";
180
181 $map{"rgarciasuarez\100mandrakesoft.com"}
182   = $map{"rgarciasuarez\100mandriva.com"}
183   = $map{"raphel.garcia-suarez\100hexaflux.com"} = "rgs";
184 $map{"jhietaniemi\100gmail.com"} = $map{"jhi\100kosh.hut.fi"}
185   = $map{"jhi\100cc.hut.fi"} = $map{"jarkko.hietaniemi\100nokia.com"} = "jhi";
186 $map{"nick\100ccl4.org"} = $map{"nick\100talking.bollo.cx"}
187   = $map{"nick\100plum.flirble.org"} = $map{"nick\100babyhippo.co.uk"}
188   = $map{"nick\100bagpuss.unfortu.net"} = "nicholas";
189 $map{"craig.berry\100psinetcs.com"} = $map{"craig.berry\100metamorgs.com"}
190   = $map{"craig.berry\100signaltreesolutions.com"}
191   = $map{"craigberry\100mac.com"} = "craigb";
192 $map{"davem\100iabyn.nospamdeletethisbit.com" }
193   = $map{"davem\100fdgroup.co.uk"} = $map{"davem\100fdisolutions.com"}
194  = "davem";
195 $map{"alan.burlison\100uk.sun.com"} = "alanbur";
196 $map{"artur\100contiller.se"} = $map{"arthur\100contiller.se"} = "sky";
197 $map{"h.m.brand\100hccnet.nl"} = $map{"merijn\100l1.procura.nl"} = "merijn";
198 $map{"nik\100tiuk.ti.com"} = $map{"nick.ing-simmons\100elixent.com"} = "nick";
199 $map{"hv\100crypt.org"} = "hv";
200 $map{"gisle\100aas.no"} = "gisle";
201 $map{"gsar\100cpan.org"} = "gsar";
202
203 if (@authors) {
204   my %raw;
205   foreach my $filename (@authors) {
206     open FH, "<$filename" or die "Can't open $filename: $!";
207     while (<FH>) {
208       next if /^\#/;
209       next if /^-- /;
210       if (/<([^>]+)>/) {
211         # Easy line.
212         $raw{$1}++;
213       } elsif (/^([-A-Za-z0-9 .\'À-ÖØöø-ÿ]+)[\t\n]/) {
214         # Name only
215         $untraced{$1}++;
216       } else {
217         chomp;
218         warn "Can't parse line '$_'";
219       }
220     }
221   }
222   foreach (keys %raw) {
223     print "E-mail $_ occurs $raw{$_} times\n" if $raw{$_} > 1;
224     $_ = lc $_;
225     $authors{$map{$_} || $_}++;
226   }
227   ++$authors{'!'};
228   ++$authors{'?'};
229 }
230
231 while (<>) {
232   next if /^-+/;
233   if (m!^\[\s+(\d+)\]\s+By:\s+(\S+)\s+on!) {
234     # new patch
235     my @new = ($1, $2);
236     &process ($committer, $patch, $log);
237     ($patch, $committer) = @new;
238     undef $log;
239   } elsif (s/^(\s+Log: )//) {
240     die "Duplicate Log:" if $log;
241     $log = $_;
242     my $prefix = " " x length $1;
243     LOG: while (<>) {
244       next if /^$/;
245       s/^\t/        /;
246       if (s/^$prefix//) {
247         $log .= $_;
248       } elsif (/^\s+Branch:/) {
249         last LOG;
250       } else {
251         chomp;
252         die "Malformed log end with '$_'";
253       }
254     }
255   }
256 }
257
258 &process ($committer, $patch, $log);
259
260 if ($rank) {
261   &display_ordered(\%patchers);
262 } elsif ($ta) {
263   &display_ordered(\%committers);
264 } elsif (%authors) {
265   my %missing;
266   foreach (sort keys %patchers) {
267     next if $authors{$_};
268     # Sort by number of patches, then name.
269     $missing{$patchers{$_}}->{$_}++;
270   }
271   foreach my $patches (sort {$b <=> $a} keys %missing) {
272     print "$patches patch(es)\n";
273     foreach my $author (sort keys %{$missing{$patches}}) {
274       print "  $author\n";
275     }
276   }
277 }
278
279 sub display_ordered {
280   my $what = shift;
281   my @sorted;
282   my $total;
283   while (my ($name, $count) = each %$what) {
284     push @{$sorted[$count]}, $name;
285     $total += $count;
286   }
287
288   my $i = @sorted;
289   return unless @sorted;
290   my $sum = 0;
291   foreach my $i ($reverse ? 0 .. $#sorted : reverse 0 .. $#sorted) {
292     next unless $sorted[$i];
293     my $prefix;
294     $sum += $i * @{$sorted[$i]};
295     # Value to display is either this one, or the cumulative sum.
296     my $value = $cumulative ? $sum : $i;
297     if ($percentage) {
298         $prefix = sprintf "%6.2f:\t", 100 * $value / $total;
299     } else {
300         $prefix = "$value:\t";
301     }
302     print wrap ($prefix, "\t", join (" ", sort @{$sorted[$i]}), "\n");
303   }
304 }
305
306 sub process {
307   my ($committer, $patch, $log) = @_;
308   return unless $committer;
309   my @authors = $log =~ /From:\s+.*?([^"\@ \t\n<>]+\@[^"\@ \t\n<>]+)/gm;
310
311   if (@authors) {
312     foreach (@authors) {
313       s/^<//;
314       s/>$//;
315       $_ = lc $_;
316       $patchers{$map{$_} || $_}++;
317     }
318     # print "$patch: @authors\n";
319     ++$committers{$committer};
320   } else {
321     # print "$patch: $committer\n";
322     # Not entirely fair as this means that the maint pumpking scores for
323     # everything intergrated that wasn't a third party patch in blead
324     $patchers{$committer}++;
325   }
326 }
327
328