This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
798dd0c6ee3f4f6fffa3375157385de80a397025
[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, @authors, %authors, %untraced, %patchers);
9 my $result = GetOptions ("rank" => \$rank,                      # rank authors
10                          "acknowledged=s"   => \@authors);      # authors files
11
12 if (!$result or !($rank xor @authors) or !@ARGV) {
13   die <<"EOS";
14 $0 --rank Changelogs                        # rank authors by patches
15 $0 --acknowledged <authors file> Changelogs # Display unacknowledged authors
16 Specify stdin as - if needs be. Remember that option names can be abbreviated.
17 EOS
18 }
19
20 my %map = reverse (
21                    # "Correct" => "Alias"
22                    adi => "enache\100rdslink.ro",
23                    alanbur => "alan.burlison\100sun.com",
24                    ams => "ams\100wiw.org",
25                    chip => "chip\100pobox.com",
26                    davem => "davem\100fdgroup.com",
27                    doughera => " doughera\100lafayette.edu",
28                    gbarr => "gbarr\100pobox.com",
29                    gsar => "gsar\100activestate.com",
30                    hv => "hv\100crypt.compulink.co.uk",
31                    jhi => "jhi\100iki.fi",
32                    merijn => "h.m.brand\100xs4all.nl",
33                    mhx => "mhx-perl\100gmx.net",
34                    nicholas => "nick\100unfortu.net",
35                    nick => "nick\100ing-simmons.net",
36                    pudge => "pudge\100pobox.com",
37                    rgs => "rgarciasuarez\100free.fr",
38                    sky => "sky\100nanisky.com", 
39                    steveh => "steve.hay\100uk.radan.com",
40                    stevep => "steve\100fisharerojo.org",
41                    gisle => "gisle\100activestate.com",
42                    "abigail\100abigail.nl"=> "abigail\100foad.org",
43                    "chromatic\100wgz.org" => "chromatic\100rmci.net",
44                    "slaven\100rezic.de" => "slaven.rezic\100berlin.de",
45                    "mjtg\100cam.ac.uk" => "mjtg\100cus.cam.ac.uk",
46                    "robin.barker\100npl.co.uk" => "rmb1\100cise.npl.co.uk",
47                    "paul.marquess\100btinternet.com"
48                    => "paul_marquess\100yahoo.co.uk",
49                    "wolfgang.laun\100chello.at" =>
50                    "wolfgang.laun\100alcatel.at",
51                    "t.jenness\100jach.hawaii.edu" => "timj\100jach.hawaii.edu",
52                    "abe\100ztreet.demon.nl" => "abeltje\100cpan.org",
53                    "nospam-abuse\100bloodgate.com" => "tels\100bloodgate.com",
54                    "jfriedl\100yahoo.com" => "jfriedl\100yahoo-inc.com",
55                    "japhy\100pobox.com" => "japhy\100pobox.org",
56                    "gellyfish\100gellyfish.com" => "jns\100gellyfish.com",
57                    "jcromie\100divsol.com" => "jcromie\100cpan.org",
58                    "demerphq\100gmail.com" => "demerphq\100hotmail.com",
59                    "rick\100consumercontact.com" => "rick\100bort.ca",
60                    "vkonovalov\100spb.lucent.com"
61                    => "vkonovalov\100peterstar.ru",
62                    "rjk\100linguist.dartmouth.edu"
63                    => "rjk\100linguist.thayer.dartmouth.edu",
64                    "domo\100computer.org" => "shouldbedomo\100mac.com",
65                    "kane\100dwim.org" => "kane\100xs4all.net",
66                    "allens\100cpan.org" => "easmith\100beatrice.rutgers.edu",
67                    "spoon\100cpan.org" => "spoon\100dellah.org",
68                    "ben_tilly\100operamail.com" => "btilly\100gmail.com",
69                    "mbarbon\100dsi.unive.it" => "mattia.barbon\100libero.it",
70                    "tassilo.parseval\100post.rwth-aachen.de" =>
71                    "tassilo.von.parseval\100rwth-aachen.de",
72                    "dcd\100tc.fluke.com" => "david.dyck\100fluke.com",
73                    "kroepke\100dolphin-services.de"
74                    => "kay\100dolphin-services.de",
75                    "sebastien\100aperghis.net" => "maddingue\100free.fr",
76                    "radu\100netsoft.ro" => "rgreab\100fx.ro",
77                    "rick\100consumercontact.com"
78                    => "rick.delaney\100rogers.com",
79                    "p5-authors\100crystalflame.net"
80                    => "perl\100crystalflame.net",
81                    "stef\100mongueurs.net" => "stef\100payrard.net",
82                    "kstar\100wolfetech.com" => "kstar\100cpan.org",
83                    "7k8lrvf02\100sneakemail.com" =>
84                    "kjx9zthh3001\100sneakemail.com",
85                    "mgjv\100comdyn.com.au" => "mgjv\100tradingpost.com.au",
86                    "thomas.dorner\100start.de" => "tdorner\100amadeus.net",
87                    "ajohnson\100nvidia.com" => "ajohnson\100wischip.com",
88                    "phil\100perkpartners.com" => "phil\100finchcomputer.com",
89                    # Maybe we should special case this to get real names out?
90                    "perlbug\100perl.org" => "perlbug-followup\100perl.org",
91                   );
92
93 # Make sure these are all lower case.
94
95 $map{"alan.burlison\100uk.sun.com"} = "alanbur";
96 $map{"artur\100contiller.se"} = $map{"arthur\100contiller.se"} = "sky";
97 $map{"autrijus\100egb.elixus.org"} = $map{"autrijus\100geb.elixus.org"}
98   = "autrijus\100autrijus.org";
99 $map{"craig.berry\100psinetcs.com"} = $map{"craig.berry\100metamorgs.com"}
100   = $map{"craig.berry\100signaltreesolutions.com"}
101   = $map{"craigberry\100mac.com"} = "craigb";
102 $map{"davem\100iabyn.nospamdeletethisbit.com" }
103   = $map{"davem\100fdgroup.co.uk"} = "davem";
104 $map{"ilya\100math.ohio-state.edu"} = $map{"ilya\100math.berkeley.edu"}
105   = $map{"ilya\100math.berkeley.edu"} = "nospam-abuse\100ilyaz.org";
106 $map{"jhietaniemi\100gmail.com"} = $map{"jhi\100kosh.hut.fi"}
107   = $map{"jhi\100cc.hut.fi"} = "jhi";
108 $map{"nick\100ccl4.org"} = $map{"nick\100talking.bollo.cx"}
109   = $map{"nick\100plum.flirble.org"} = $map{"nick\100babyhippo.co.uk"}
110   = $map{"nick\100bagpuss.unfortu.net"} = "nicholas";
111 $map{"philip.newton\100gmx.net"} = $map{"philip.newton\100datenrevision.de"}
112   = $map{"pnewton\100gmx.de"} = "pne\100cpan.org",
113 $map{"rgarciasuarez\100mandrakesoft.com"}
114   = $map{"rgarciasuarez\100mandriva.com"}
115   = $map{"raphel.garcia-suarez\100hexaflux.com"} = "rgs";
116 $map{"simon\100pembro4.pmb.ox.ac.uk"} = $map{"simon\100brecon.co.uk"}
117   = $map{"simon\100othersideofthe.earth.li"} = $map{"simon\100cozens.net"}
118   = $map{"simon\100netthink.co.uk"} = "simon\100simon-cozens.org";
119 $map{"spider\100web.zk3.dec.com"} = $map{"spider\100leggy.zk3.dec.com"}
120   = $map{"spider-perl\100orb.nashua.nh.us"}
121   = $map{"spider\100peano.zk3.dec.com"}
122   = "spider\100orb.nashua.nh.us";
123 $map{"nik\100tiuk.ti.com"} = "nick";
124
125 $map{"a.koenig\100mind.de"} = "andreas.koenig\100anima.de";
126 $map{"japhy\100perlmonk.org"} = $map{"japhy\100cpan.org"}
127   = "japhy\100pobox.com";
128 $map{"rmbarker\100cpan.org"} = "robin.barker\100npl.co.uk";
129
130 $map{"h.m.brand\100hccnet.nl"} = $map{"merijn\100l1.procura.nl"} = "merijn";
131
132 $map{"yves.orton\100de.mci.com"} = $map{"yves.orton\100mciworldcom.de"}
133   = "demerphq\100gmail.com";
134 $map{"jim.cromie\100gmail.com"} = "jcromie\100divsol.com";
135 $map{"perl_dummy\100bloodgate.com"} = "nospam-abuse\100bloodgate.com";
136 $map{"paul.marquess\100ntlworld.com"} = "paul.marquess\100btinternet.com";
137 $map{"konovalo\100mail.wplus.net"} = $map{"vadim\100vkonovalov.ru"}
138   = "vkonovalov\100spb.lucent.com";
139 $map{"kane\100cpan.org"} = "kane\100dwim.org";
140 $map{"rs\100crystalflame.net"} = "p5-authors\100crystalflame.net";
141 $map{"(srezic\100iconmobile.com)"} = "slaven\100rezic.de";
142 $map{"perl\100dellah.anu.edu.au"} = "spoon\100cpan.org";
143
144 $map{"hv\100crypt.org"} = "hv";
145 $map{"gisle\100aas.no"} = "gisle";
146
147 if (@authors) {
148   my %raw;
149   foreach my $filename (@authors) {
150     open FH, "<$filename" or die "Can't open $filename: $!";
151     while (<FH>) {
152       next if /^\#/;
153       next if /^-- /;
154       if (/<([^>]+)>/) {
155         # Easy line.
156         $raw{$1}++;
157       } elsif (/^([-A-Za-z0-9 .\'À-ÖØöø-ÿ]+)[\t\n]/) {
158         # Name only
159         $untraced{$1}++;
160       } else {
161         chomp;
162         warn "Can't parse line '$_'";
163       }
164     }
165   }
166   foreach (keys %raw) {
167     print "E-mail $_ occurs $raw{$_} times\n" if $raw{$_} > 1;
168     $_ = lc $_;
169     $authors{$map{$_} || $_}++;
170   }
171 }
172
173 while (<>) {
174   next if /^-+/;
175   if (m!^\[\s+(\d+)\]\s+By:\s+(\S+)\s+on!) {
176     # new patch
177     my @new = ($1, $2);
178     &process ($committer, $patch, $log);
179     ($patch, $committer) = @new;
180     undef $log;
181   } elsif (s/^(\s+Log: )//) {
182     die "Duplicate Log:" if $log;
183     $log = $_;
184     my $prefix = " " x length $1;
185     LOG: while (<>) {
186       next if /^$/;
187       if (s/^$prefix//) {
188         $log .= $_;
189       } elsif (/^\s+Branch:/) {
190         last LOG;
191       } else {
192         chomp;
193         die "Malformed log end with '$_'";
194       }
195     }
196   }
197 }
198
199 &process ($committer, $patch, $log);
200
201 if ($rank) {
202   &display_ordered;
203 } elsif (%authors) {
204   my %missing;
205   foreach (sort keys %patchers) {
206     next if $authors{$_};
207     # Sort by number of patches, then name.
208     $missing{$patchers{$_}}->{$_}++;
209   }
210   foreach my $patches (sort {$b <=> $a} keys %missing) {
211     print "$patches patch(es)\n";
212     foreach my $author (sort keys %{$missing{$patches}}) {
213       print "  $author\n";
214     }
215   }
216 }
217
218 sub display_ordered {
219   my @sorted;
220   while (my ($name, $count) = each %patchers) {
221     push @{$sorted[$count]}, $name;
222   }
223
224   my $i = @sorted;
225   return unless $i;
226   while (--$i) {
227     next unless $sorted[$i];
228     print wrap ("$i:\t", "\t", join (" ", sort @{$sorted[$i]}), "\n");
229   }
230 }
231
232 sub process {
233   my ($committer, $patch, $log) = @_;
234   return unless $committer;
235   my @authors = $log =~ /From:.+\s+([^\@ \t\n]+\@[^\@ \t\n]+)/gm;
236
237   if (@authors) {
238     foreach (@authors) {
239       s/^<//;
240       s/>$//;
241       $_ = lc $_;
242       $patchers{$map{$_} || $_}++;
243     }
244     # print "$patch: @authors\n";
245   } else {
246     # print "$patch: $committer\n";
247     # Not entirely fair as this means that the maint pumpking scores for
248     # everything intergrated that wasn't a third party patch in blead
249     $patchers{$committer}++;
250   }
251 }
252
253