-
Notifications
You must be signed in to change notification settings - Fork 0
/
authors.pl
executable file
·42 lines (34 loc) · 943 Bytes
/
authors.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/perl
#
# This script can generate commit statistics from 'git log --shortstat -z tag1..tag2' output
#
use strict;
use warnings;
local $/ = "\x0";
my %auth;
our $commits;
our $insertions;
our $deletions;
our $author;
my $input;
if (@ARGV > 0) {
open $input, "git log --shortstat -z --minimal -w -C $ARGV[0]|" or die "cannot open pipe for $ARGV[0]: $!\n";
} else {
$input = \*STDIN;
}
while (<$input>) {
($author) = /Author: (.*) </;
my ($insert, $delete) = /files changed, (\d+) insert.* (\d+) delet/;
next unless defined $insert;
$auth{$author} = [0, 0, 0] unless defined($auth{$author});
my @l = @{$auth{$author}};
$auth{$author} = [$l[0] + 1, $l[1] + $insert, $l[2] + $delete];
}
for $author (sort { $auth{$b}->[0] <=> $auth{$a}->[0] } keys %auth) {
($commits, $insertions, $deletions) = @{$auth{$author}};
write;
}
format STDOUT =
@#### @###### @###### @*
$commits, $insertions, $deletions, $author
.