Skip to content
Newer
Older
100644 84 lines (73 sloc) 2.28 KB
c868fc1 @moritz [tools] new script contributors.pl
moritz authored Apr 27, 2010
1 #!/usr/bin/env perl
2 use strict;
3 use warnings;
4 binmode STDOUT, ':encoding(UTF-8)';
18af942 @arnsholt [tools] Make contributors.pl compatible with Perl 5.8.
arnsholt authored Feb 17, 2011
5 #use 5.010;
56b25a2 @moritz [tools/contributors.pl] avoid Mojibake
moritz authored Jul 22, 2010
6 use utf8;
c868fc1 @moritz [tools] new script contributors.pl
moritz authored Apr 27, 2010
7
8 use Date::Simple qw(today ymd);
9
10 my %contrib;
11
18af942 @arnsholt [tools] Make contributors.pl compatible with Perl 5.8.
arnsholt authored Feb 17, 2011
12 my $last_release = shift;
13 $last_release = release_date_of_prev_month() if not defined $last_release;
14 my $nick_to_name = nick_to_name_from_CREDITS();
c868fc1 @moritz [tools] new script contributors.pl
moritz authored Apr 27, 2010
15 open my $c, '-|', 'git', 'log', "--since=$last_release", '--pretty=format:%an|%cn|%s'
16 or die "Can't open pipe to git log: $!";
56b25a2 @moritz [tools/contributors.pl] avoid Mojibake
moritz authored Jul 22, 2010
17 binmode $c, ':encoding(UTF-8)';
c868fc1 @moritz [tools] new script contributors.pl
moritz authored Apr 27, 2010
18 while (my $line = <$c>) {
19 my ($author, $comitter, $msg) = split /\|/, $line, 3;
20 $contrib{nick_to_name($author)}++;
93ec069 @Util Added Ingy to CREDITS; made contributors.pl work with UTF-8 and ignor…
Util authored Jul 22, 2010
21 $contrib{nick_to_name($comitter)}++ if $comitter ne 'Rakudo Perl';
ef228dd @perlpilot Minor improvement to contributors.pl
perlpilot authored Sep 20, 2012
22 while ($msg =~ /\(([^)]{2,})\)\+\+/g) {
c868fc1 @moritz [tools] new script contributors.pl
moritz authored Apr 27, 2010
23 $contrib{nick_to_name($1)}++;
24 }
ef228dd @perlpilot Minor improvement to contributors.pl
perlpilot authored Sep 20, 2012
25 while ($msg =~ /([^\s():]{2,})\+\+/g) {
bc27f76 @perlpilot minor improvement to contributor search
perlpilot authored Oct 20, 2011
26 my $nick = $1;
27 next if $nick =~ /^[\$\@]/;
28 $contrib{nick_to_name($nick)}++;
c868fc1 @moritz [tools] new script contributors.pl
moritz authored Apr 27, 2010
29 }
7e8134c @moritz [tools/contributors.pl] avoid infinite recursion, general cleanup
moritz authored Jul 28, 2010
30 while ($msg =~ /courtesy of:?\s*(\S.*)/gi) {
c868fc1 @moritz [tools] new script contributors.pl
moritz authored Apr 27, 2010
31 $contrib{nick_to_name($1)}++;
32 }
33 }
34 close $c or warn $!;
35
36 my @contrib = reverse sort { $contrib{$a} <=> $contrib{$b} } keys %contrib;
37
38 print "Contributors to Rakudo since the release on $last_release:\n";
39 print join(', ', @contrib), "\n";
40
41
42 sub release_date_of_prev_month {
43 my $release_date;
44 my $last_month = today();
45 $last_month-- while $last_month->month == today->month;
46 $release_date = ymd(
47 $last_month->year,
48 $last_month->month,
49 1,
50 );
51 $release_date++ while $release_date->day_of_week != 2;
52 $release_date += 14;
53 $release_date++ while $release_date->day_of_week != 4;
54 return $release_date;
55 }
56
57 sub nick_to_name_from_CREDITS {
93ec069 @Util Added Ingy to CREDITS; made contributors.pl work with UTF-8 and ignor…
Util authored Jul 23, 2010
58 open my $f, '<:utf8', 'CREDITS' or die "Can't open file CREDITS for reading: $!";
c868fc1 @moritz [tools] new script contributors.pl
moritz authored Apr 27, 2010
59 local $/ = '';
60 my %nicks;
61 while (my $para = <$f>) {
62 my @nicks;
63 my $name;
64 for (split /\n/, $para) {
65 if (/^N: (.*)/) {
66 $name = $1;
67 } elsif (/^U: (.*)/) {
68 push @nicks, $1;
69 }
70 }
71 if (defined $name) {
72 $nicks{lc $_} = $name for @nicks;
73 }
74 }
75 close $f;
76 return \%nicks;
77 }
78
79 sub nick_to_name {
80 my $nick = shift;
18af942 @arnsholt [tools] Make contributors.pl compatible with Perl 5.8.
arnsholt authored Feb 17, 2011
81 return defined $nick_to_name->{lc $nick}? $nick_to_name->{lc $nick} : $nick;
c868fc1 @moritz [tools] new script contributors.pl
moritz authored Apr 27, 2010
82 }
83
Something went wrong with that request. Please try again.