Skip to content
Newer
Older
100644 63 lines (55 sloc) 1.49 KB
ead1a2d @moritz Introducing tools/commit-stats.pl
moritz authored
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4 use GD::Graph::linespoints;
5 use List::Util qw(max);
6 use POSIX qw(log10 ceil);
7
8 open my $c, '-|', qw(git log --pretty=format:%ae|%ci)
9 or die "Can't run git log: $!";
10
11 my %email;
12 my %month;
13
14 while (<$c>) {
15 chomp;
16 my ($email, $date) = split /\|/;
17 $email{$email}++;
18 $month{substr $date, 0, 7}++;
19 }
20 close $c or die $!;
21
22 {
23 my $max = max values %month;
24 my $round = 10 ** int(log10 $max);
25 $max = $round * (1 + int($max / $round));
26 my $label_skip = int .5 + (values %month) / 20;
27
28 my $g = GD::Graph::linespoints->new(600, 400);
29 $g->set(
30 x_label => 'Month',
31 y_label => 'Number of commits',
32 title => 'Commits to Rakudo per Month',
33 x_label_skip => $label_skip,
34 x_labels_vertical => 1,
35 y_max_value => $max,
36 y_min_value => 0,
37
38 ) or die $g->error;
39 my @data;
40 my $c = 0;
41 for (sort keys %month){
42 push @{$data[0]}, $_;
43 push @{$data[1]}, $month{$_};
44 }
45 my $filename = $ARGV[0] || 'commits.png';
46 open my $img, '>', $filename
47 or die "Can't open `$filename' for writing: $!";
48 binmode $img;
49 print $img $g->plot(\@data)->png;
50 close $img;
51 }
52
53 {
54 my $top = 15;
55 my $c = 0;
56 print "Top $top commit authors\n";
57 for (sort { $email{$b} <=> $email{$a} } keys %email) {
58 $c++;
59 printf "%-2d % 5d %s\n", $c, $email{$_}, $_;
60 last if $c >= $top;
61 }
62 }
Something went wrong with that request. Please try again.