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