This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Teach the alias mapping about new committers.
[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                    "abigail\100abigail.nl"=> "abigail\100foad.org",
42                    "chromatic\100wgz.org" => "chromatic\100rmci.net",
43                    "slaven\100rezic.de" => "slaven.rezic\100berlin.de",
44                    "mjtg\100cam.ac.uk" => "mjtg\100cus.cam.ac.uk",
45                    "robin.barker\100npl.co.uk" => "rmb1\100cise.npl.co.uk",
46                    "paul.marquess\100btinternet.com"
47                    => "paul_marquess\100yahoo.co.uk",
48                    "wolfgang.laun\100chello.at" =>
49                    "wolfgang.laun\100alcatel.at",
50                    "t.jenness\100jach.hawaii.edu" => "timj\100jach.hawaii.edu",
51                    "abe\100ztreet.demon.nl" => "abeltje\100cpan.org",
52                    "perl_dummy\100bloodgate.com" => "tels\100bloodgate.com",
53                    "jfriedl\100yahoo.com" => "jfriedl\100yahoo-inc.com",
54                    "japhy\100pobox.com" => "japhy\100pobox.org",
55                    "gellyfish\100gellyfish.com" => "jns\100gellyfish.com",
56                   );
57
58 # Make sure these are all lower case.
59
60 $map{"alan.burlison\100uk.sun.com"} = "alanbur";
61 $map{"artur\100contiller.se"} = $map{"arthur\100contiller.se"} = "sky";
62 $map{"autrijus\100egb.elixus.org"} = $map{"autrijus\100geb.elixus.org"}
63   = "autrijus\100autrijus.org";
64 $map{"craig.berry\100psinetcs.com"} = $map{"craig.berry\100metamorgs.com"}
65   = $map{"craig.berry\100signaltreesolutions.com"}
66   = $map{"craigberry\100mac.com"} = "craigb";
67 $map{"davem\100fdgroup.co.uk"} = "davem";
68 $map{"ilya\100math.ohio-state.edu"} = $map{"ilya\100math.berkeley.edu"}
69   = $map{"ilya\100math.berkeley.edu"} = "nospam-abuse\100ilyaz.org";
70 $map{"jhi\100kosh.hut.fi"} = $map{"jhi\100cc.hut.fi"} = "jhi";
71 $map{"nick\100ccl4.org"} = $map{"nick\100talking.bollo.cx"}
72   = $map{"nick\100plum.flirble.org"} = $map{"nick\100babyhippo.co.uk"}
73   = $map{"nick\100bagpuss.unfortu.net"} = "nicholas";
74 $map{"philip.newton\100gmx.net"} = $map{"philip.newton\100datenrevision.de"}
75   = "pnewton\100gmx.de",
76 $map{"raphel.garcia-suarez\100hexaflux.com"} = "rgs";
77 $map{"simon\100pembro4.pmb.ox.ac.uk"} = $map{"simon\100brecon.co.uk"}
78   = $map{"simon\100othersideofthe.earth.li"} = $map{"simon\100cozens.net"}
79   = $map{"simon\100netthink.co.uk"} = "simon\100simon-cozens.org";
80 $map{"spider\100web.zk3.dec.com"} = $map{"spider\100leggy.zk3.dec.com"}
81   = $map{"spider-perl\100orb.nashua.nh.us"}
82   = $map{"spider\100peano.zk3.dec.com"}
83   = "spider\100orb.nashua.nh.us";
84 $map{"nik\100tiuk.ti.com"} = "nick";
85
86 $map{"a.koenig\100mind.de"} = "andreas.koenig\100anima.de";
87 $map{"japhy\100perlmonk.org"} = $map{"japhy\100cpan.org"}
88   = "japhy\100pobox.com";
89 $map{"rmbarker\100cpan.org"} = "robin.barker\100npl.co.uk";
90
91 if (@authors) {
92   my %raw;
93   foreach my $filename (@authors) {
94     open FH, "<$filename" or die "Can't open $filename: $!";
95     while (<FH>) {
96       next if /^\#/;
97       next if /^-- /;
98       if (/<([^>]+)>/) {
99         # Easy line.
100         $raw{$1}++;
101       } elsif (/^([-A-Za-z0-9 .\'À-ÖØöø-ÿ]+)[\t\n]/) {
102         # Name only
103         $untraced{$1}++;
104       } else {
105         chomp;
106         warn "Can't parse line '$_'";
107       }
108     }
109   }
110   foreach (keys %raw) {
111     print "E-mail $_ occurs $raw{$_} times\n" if $raw{$_} > 1;
112     $_ = lc $_;
113     $authors{$map{$_} || $_}++;
114   }
115 }
116
117 while (<>) {
118   next if /^-+/;
119   if (m!^\[\s+(\d+)\]\s+By:\s+(\S+)\s+on!) {
120     # new patch
121     my @new = ($1, $2);
122     &process ($committer, $patch, $log);
123     ($patch, $committer) = @new;
124     undef $log;
125   } elsif (s/^(\s+Log: )//) {
126     die "Duplicate Log:" if $log;
127     $log = $_;
128     my $prefix = " " x length $1;
129     LOG: while (<>) {
130       next if /^$/;
131       if (s/^$prefix//) {
132         $log .= $_;
133       } elsif (/^\s+Branch:/) {
134         last LOG;
135       } else {
136         chomp;
137         die "Malformed log end with '$_'";
138       }
139     }
140   }
141 }
142
143 &process ($committer, $patch, $log);
144
145 if ($rank) {
146   &display_ordered;
147 } elsif (%authors) {
148   my %missing;
149   foreach (sort keys %patchers) {
150     next if $authors{$_};
151     # Sort by number of patches, then name.
152     $missing{$patchers{$_}}->{$_}++;
153   }
154   foreach my $patches (sort {$b <=> $a} keys %missing) {
155     print "$patches patch(es)\n";
156     foreach my $author (sort keys %{$missing{$patches}}) {
157       print "  $author\n";
158     }
159   }
160 }
161
162 sub display_ordered {
163   my @sorted;
164   while (my ($name, $count) = each %patchers) {
165     push @{$sorted[$count]}, $name;
166   }
167
168   my $i = @sorted;
169   while (--$i) {
170     next unless $sorted[$i];
171     print wrap ("$i:\t", "\t", join (" ", sort @{$sorted[$i]}), "\n");
172   }
173 }
174
175 sub process {
176   my ($committer, $patch, $log) = @_;
177   return unless $committer;
178   my @authors = $log =~ /From:.+\s+([^\@ \t\n]+\@[^\@ \t\n]+)/gm;
179
180   if (@authors) {
181     foreach (@authors) {
182       s/^<//;
183       s/>$//;
184       $_ = lc $_;
185       $patchers{$map{$_} || $_}++;
186     }
187     # print "$patch: @authors\n";
188   } else {
189     # print "$patch: $committer\n";
190     # Not entirely fair as this means that the maint pumpking scores for
191     # everything intergrated that wasn't a third party patch in blead
192     $patchers{$committer}++;
193   }
194 }
195
196