This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
ab4abbeeeb7618e33c95f97640ad8f0604d90589
[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 $map{"h.m.brand\100hccnet.nl"} = 'merijn';
92
93 if (@authors) {
94   my %raw;
95   foreach my $filename (@authors) {
96     open FH, "<$filename" or die "Can't open $filename: $!";
97     while (<FH>) {
98       next if /^\#/;
99       next if /^-- /;
100       if (/<([^>]+)>/) {
101         # Easy line.
102         $raw{$1}++;
103       } elsif (/^([-A-Za-z0-9 .\'À-ÖØöø-ÿ]+)[\t\n]/) {
104         # Name only
105         $untraced{$1}++;
106       } else {
107         chomp;
108         warn "Can't parse line '$_'";
109       }
110     }
111   }
112   foreach (keys %raw) {
113     print "E-mail $_ occurs $raw{$_} times\n" if $raw{$_} > 1;
114     $_ = lc $_;
115     $authors{$map{$_} || $_}++;
116   }
117 }
118
119 while (<>) {
120   next if /^-+/;
121   if (m!^\[\s+(\d+)\]\s+By:\s+(\S+)\s+on!) {
122     # new patch
123     my @new = ($1, $2);
124     &process ($committer, $patch, $log);
125     ($patch, $committer) = @new;
126     undef $log;
127   } elsif (s/^(\s+Log: )//) {
128     die "Duplicate Log:" if $log;
129     $log = $_;
130     my $prefix = " " x length $1;
131     LOG: while (<>) {
132       next if /^$/;
133       if (s/^$prefix//) {
134         $log .= $_;
135       } elsif (/^\s+Branch:/) {
136         last LOG;
137       } else {
138         chomp;
139         die "Malformed log end with '$_'";
140       }
141     }
142   }
143 }
144
145 &process ($committer, $patch, $log);
146
147 if ($rank) {
148   &display_ordered;
149 } elsif (%authors) {
150   my %missing;
151   foreach (sort keys %patchers) {
152     next if $authors{$_};
153     # Sort by number of patches, then name.
154     $missing{$patchers{$_}}->{$_}++;
155   }
156   foreach my $patches (sort {$b <=> $a} keys %missing) {
157     print "$patches patch(es)\n";
158     foreach my $author (sort keys %{$missing{$patches}}) {
159       print "  $author\n";
160     }
161   }
162 }
163
164 sub display_ordered {
165   my @sorted;
166   while (my ($name, $count) = each %patchers) {
167     push @{$sorted[$count]}, $name;
168   }
169
170   my $i = @sorted;
171   while (--$i) {
172     next unless $sorted[$i];
173     print wrap ("$i:\t", "\t", join (" ", sort @{$sorted[$i]}), "\n");
174   }
175 }
176
177 sub process {
178   my ($committer, $patch, $log) = @_;
179   return unless $committer;
180   my @authors = $log =~ /From:.+\s+([^\@ \t\n]+\@[^\@ \t\n]+)/gm;
181
182   if (@authors) {
183     foreach (@authors) {
184       s/^<//;
185       s/>$//;
186       $_ = lc $_;
187       $patchers{$map{$_} || $_}++;
188     }
189     # print "$patch: @authors\n";
190   } else {
191     # print "$patch: $committer\n";
192     # Not entirely fair as this means that the maint pumpking scores for
193     # everything intergrated that wasn't a third party patch in blead
194     $patchers{$committer}++;
195   }
196 }
197
198