-
Notifications
You must be signed in to change notification settings - Fork 9
/
authors-per-month.pl
65 lines (60 loc) · 1.55 KB
/
authors-per-month.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/perl
my @a = `git log --use-mailmap --reverse --pretty=fuller --no-color --date=short --decorate=full | egrep "^(Author|CommitDate):"`;
my $c=1;
my $auth="";
for(@a) {
chomp;
my $line = $_;
if(/^Author: *([^\<]*) \</) {
($auth)=($1);
}
elsif($auth && /^CommitDate: (.*)/) {
if($1 =~ /^(\d\d\d\d)-(\d\d)/) {
$month = "$1-$2-01";
}
$uniq{$auth}++;
$uniqs{$month} = scalar(keys %uniq);
$uniqmonth{$auth.$month}++;
$total{$auth}++;
if($uniq{$auth} == 1) {
# this many did their first commit this month
$when{$month}++;
}
if($uniqmonth{$auth.$month} == 1) {
# total count of authors this month
$whenmonth{$month}++;
}
#printf "$c;%d\n", scalar(keys %uniq) if(!($c % 50));
$c++;
$auth="";
}
}
# iterate over all authors, count those who did less than three that month
for my $a (sort keys %total) {
for my $y (sort keys %when) {
#print STDERR "check $a for $y\n";
if($uniqmonth{$a.$y} && ($uniqmonth{$a.$y} < 3)) {
$driveby{$y}++;
}
}
}
sub average {
my @p = @_;
my $sum;
for my $y (@p) {
$sum += $whenmonth{$y};
}
return $sum / scalar(@p);
}
my @pp;
#print "Month; Unique Authors;
for my $y(sort keys %whenmonth) {
if($y > 2009) {
push @pp, $y;
if(scalar(@pp) > 12) {
shift @pp;
}
printf("%s;%d;%.2f\n",
$y, $whenmonth{$y}, average(@pp));
}
}