This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix up missing and duplicate AUTHORS
[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                    # Maybe we should special case this to get real names out?
69                    "perlbug\100perl.org" => "perlbug-followup\100perl.org",
70                   );
71
72 # Make sure these are all lower case.
73
74 $map{"alan.burlison\100uk.sun.com"} = "alanbur";
75 $map{"artur\100contiller.se"} = $map{"arthur\100contiller.se"} = "sky";
76 $map{"autrijus\100egb.elixus.org"} = $map{"autrijus\100geb.elixus.org"}
77   = "autrijus\100autrijus.org";
78 $map{"craig.berry\100psinetcs.com"} = $map{"craig.berry\100metamorgs.com"}
79   = $map{"craig.berry\100signaltreesolutions.com"}
80   = $map{"craigberry\100mac.com"} = "craigb";
81 $map{"davem\100iabyn.nospamdeletethisbit.com" }
82   = $map{"davem\100fdgroup.co.uk"} = "davem";
83 $map{"ilya\100math.ohio-state.edu"} = $map{"ilya\100math.berkeley.edu"}
84   = $map{"ilya\100math.berkeley.edu"} = "nospam-abuse\100ilyaz.org";
85 $map{"jhietaniemi\100gmail.com"} = $map{"jhi\100kosh.hut.fi"}
86   = $map{"jhi\100cc.hut.fi"} = "jhi";
87 $map{"nick\100ccl4.org"} = $map{"nick\100talking.bollo.cx"}
88   = $map{"nick\100plum.flirble.org"} = $map{"nick\100babyhippo.co.uk"}
89   = $map{"nick\100bagpuss.unfortu.net"} = "nicholas";
90 $map{"philip.newton\100gmx.net"} = $map{"philip.newton\100datenrevision.de"}
91   = $map{"pnewton\100gmx.de"} = "pne\100cpan.org",
92 $map{"rgarciasuarez\100mandrakesoft.com"}
93   = $map{"rgarciasuarez\100mandriva.com"}
94   = $map{"raphel.garcia-suarez\100hexaflux.com"} = "rgs";
95 $map{"simon\100pembro4.pmb.ox.ac.uk"} = $map{"simon\100brecon.co.uk"}
96   = $map{"simon\100othersideofthe.earth.li"} = $map{"simon\100cozens.net"}
97   = $map{"simon\100netthink.co.uk"} = "simon\100simon-cozens.org";
98 $map{"spider\100web.zk3.dec.com"} = $map{"spider\100leggy.zk3.dec.com"}
99   = $map{"spider-perl\100orb.nashua.nh.us"}
100   = $map{"spider\100peano.zk3.dec.com"}
101   = "spider\100orb.nashua.nh.us";
102 $map{"nik\100tiuk.ti.com"} = "nick";
103
104 $map{"a.koenig\100mind.de"} = "andreas.koenig\100anima.de";
105 $map{"japhy\100perlmonk.org"} = $map{"japhy\100cpan.org"}
106   = "japhy\100pobox.com";
107 $map{"rmbarker\100cpan.org"} = "robin.barker\100npl.co.uk";
108
109 $map{"h.m.brand\100hccnet.nl"} = $map{"merijn\100l1.procura.nl"} = "merijn";
110
111 $map{"yves.orton\100de.mci.com"} = $map{"yves.orton\100mciworldcom.de"}
112   = "demerphq\100hotmail.com";
113 $map{"jim.cromie\100gmail.com"} = "jcromie\100divsol.com";
114 $map{"perl_dummy\100bloodgate.com"} = "nospam-abuse\100bloodgate.com";
115 $map{"paul.marquess\100ntlworld.com"} = "paul.marquess\100btinternet.com";
116 $map{"vadim\100vkonovalov.ru"} = "vkonovalov\100spb.lucent.com";
117
118 $map{"hv\100crypt.org"} = "hv";
119 $map{"gisle\100aas.no"} = "gisle";
120
121 if (@authors) {
122   my %raw;
123   foreach my $filename (@authors) {
124     open FH, "<$filename" or die "Can't open $filename: $!";
125     while (<FH>) {
126       next if /^\#/;
127       next if /^-- /;
128       if (/<([^>]+)>/) {
129         # Easy line.
130         $raw{$1}++;
131       } elsif (/^([-A-Za-z0-9 .\'À-ÖØöø-ÿ]+)[\t\n]/) {
132         # Name only
133         $untraced{$1}++;
134       } else {
135         chomp;
136         warn "Can't parse line '$_'";
137       }
138     }
139   }
140   foreach (keys %raw) {
141     print "E-mail $_ occurs $raw{$_} times\n" if $raw{$_} > 1;
142     $_ = lc $_;
143     $authors{$map{$_} || $_}++;
144   }
145 }
146
147 while (<>) {
148   next if /^-+/;
149   if (m!^\[\s+(\d+)\]\s+By:\s+(\S+)\s+on!) {
150     # new patch
151     my @new = ($1, $2);
152     &process ($committer, $patch, $log);
153     ($patch, $committer) = @new;
154     undef $log;
155   } elsif (s/^(\s+Log: )//) {
156     die "Duplicate Log:" if $log;
157     $log = $_;
158     my $prefix = " " x length $1;
159     LOG: while (<>) {
160       next if /^$/;
161       if (s/^$prefix//) {
162         $log .= $_;
163       } elsif (/^\s+Branch:/) {
164         last LOG;
165       } else {
166         chomp;
167         die "Malformed log end with '$_'";
168       }
169     }
170   }
171 }
172
173 &process ($committer, $patch, $log);
174
175 if ($rank) {
176   &display_ordered;
177 } elsif (%authors) {
178   my %missing;
179   foreach (sort keys %patchers) {
180     next if $authors{$_};
181     # Sort by number of patches, then name.
182     $missing{$patchers{$_}}->{$_}++;
183   }
184   foreach my $patches (sort {$b <=> $a} keys %missing) {
185     print "$patches patch(es)\n";
186     foreach my $author (sort keys %{$missing{$patches}}) {
187       print "  $author\n";
188     }
189   }
190 }
191
192 sub display_ordered {
193   my @sorted;
194   while (my ($name, $count) = each %patchers) {
195     push @{$sorted[$count]}, $name;
196   }
197
198   my $i = @sorted;
199   while (--$i) {
200     next unless $sorted[$i];
201     print wrap ("$i:\t", "\t", join (" ", sort @{$sorted[$i]}), "\n");
202   }
203 }
204
205 sub process {
206   my ($committer, $patch, $log) = @_;
207   return unless $committer;
208   my @authors = $log =~ /From:.+\s+([^\@ \t\n]+\@[^\@ \t\n]+)/gm;
209
210   if (@authors) {
211     foreach (@authors) {
212       s/^<//;
213       s/>$//;
214       $_ = lc $_;
215       $patchers{$map{$_} || $_}++;
216     }
217     # print "$patch: @authors\n";
218   } else {
219     # print "$patch: $committer\n";
220     # Not entirely fair as this means that the maint pumpking scores for
221     # everything intergrated that wasn't a third party patch in blead
222     $patchers{$committer}++;
223   }
224 }
225
226