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