-
Notifications
You must be signed in to change notification settings - Fork 10
/
authors-active.pl
71 lines (61 loc) · 1.49 KB
/
authors-active.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
66
67
68
69
70
71
#!/usr/bin/perl
my @a = `git log --use-mailmap --reverse --pretty=fuller --no-color --date=short --decorate=full --since='2015-01-01' | grep -E "^(Author|CommitDate):"`;
use Time::Piece;
my %dateday;
sub days {
my ($date) = @_;
if($dateday{$date}) {
return $dateday{$date};
}
my $d = Time::Piece->strptime($date, "%Y-%m-%d");
$dateday{$date} = $d;
return $d;
}
sub delta {
my ($from, $to) = @_;
my $f = days($from);
my $t = days($to);
my $diff = $t - $f;
return int($diff->days);
}
my $auth;
my $prev;
my $pline;
for(@a) {
chomp;
my $line = $_;
if(/^Author: *([^\<]*) \</) {
($auth)=($1);
$person{$auth}++;
}
elsif(/^CommitDate: (.*)/) {
my $d = $1;
$date{$auth}=$d;
if($d eq $prev) {
next;
}
$prev = $d;
my $active12;
my $active9;
my $active6;
my $active3;
my $activew;
foreach my $p (keys %person) {
my $de = delta($date{$p}, $d);
if($de > 120) {
next;
}
$active12++ if($de < 120);
$active9++ if($de < 90);
$active6++ if($de < 60);
$active3++ if($de < 30);
$activew++ if($de < 7);
}
my $line = sprintf "%d;%d;%d;%d;%d",
$active12, $active9, $active6, $active3, $activew;
if($line ne $pline) {
printf "$d;%s\n", $line;
$pline = $line;
}
}
}