Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[tools] new script contributors.pl
extracts name of contributors from 'git log', to be included in release
announcements
  • Loading branch information
moritz committed Apr 27, 2010
1 parent 8d99ca2 commit c868fc1
Showing 1 changed file with 79 additions and 0 deletions.
79 changes: 79 additions & 0 deletions tools/contributors.pl
@@ -0,0 +1,79 @@
#!/usr/bin/env perl
use strict;
use warnings;
binmode STDOUT, ':encoding(UTF-8)';
use 5.010;

use Date::Simple qw(today ymd);

my %contrib;

my $last_release = release_date_of_prev_month();
open my $c, '-|', 'git', 'log', "--since=$last_release", '--pretty=format:%an|%cn|%s'
or die "Can't open pipe to git log: $!";
while (my $line = <$c>) {
my ($author, $comitter, $msg) = split /\|/, $line, 3;
$contrib{nick_to_name($author)}++;
$contrib{nick_to_name($comitter)}++;
while ($msg =~ /\(([^)]+)\)\+\+/g) {
$contrib{nick_to_name($1)}++;
}
while ($msg =~ /([^\s()]+)\+\+/g) {
$contrib{nick_to_name($1)}++;
}
while ($msg =~ /(couretsy by:?)\s*(\S.*)/i) {
$contrib{nick_to_name($1)}++;
}
}
close $c or warn $!;

my @contrib = reverse sort { $contrib{$a} <=> $contrib{$b} } keys %contrib;

print "Contributors to Rakudo since the release on $last_release:\n";
print join(', ', @contrib), "\n";


sub release_date_of_prev_month {
my $release_date;
my $last_month = today();
$last_month-- while $last_month->month == today->month;
$release_date = ymd(
$last_month->year,
$last_month->month,
1,
);
$release_date++ while $release_date->day_of_week != 2;
$release_date += 14;
$release_date++ while $release_date->day_of_week != 4;
return $release_date;
}

sub nick_to_name_from_CREDITS {
open my $f, '<', 'CREDITS' or die "Can't open file CREDITS for reading: $!";
local $/ = '';
my %nicks;
while (my $para = <$f>) {
my @nicks;
my $name;
for (split /\n/, $para) {
if (/^N: (.*)/) {
$name = $1;
} elsif (/^U: (.*)/) {
push @nicks, $1;
}
}
if (defined $name) {
$nicks{lc $_} = $name for @nicks;
}
}
close $f;
use Data::Dumper; print Dumper \%nicks;
return \%nicks;
}

sub nick_to_name {
my $nick = shift;
state $nick_to_name = nick_to_name_from_CREDITS();
return $nick_to_name->{lc $nick} // $nick;
}

0 comments on commit c868fc1

Please sign in to comment.