Skip to content

Instantly share code, notes, and snippets.

@bagder
Last active September 12, 2017 19:41
Show Gist options
  • Save bagder/3b662bb076a66fbd04371aa49719936d to your computer and use it in GitHub Desktop.
Save bagder/3b662bb076a66fbd04371aa49719936d to your computer and use it in GitHub Desktop.
Extract number of active authors in a git repository at the time of each commit
#!/usr/bin/perl
my @a = `git log --use-mailmap --reverse --pretty=fuller --no-color --date=short --decorate=full | egrep "^(Author|CommitDate):"`;
use Time::Piece;
sub delta {
my ($from, $to) = @_;
my $f = Time::Piece->strptime($from, "%Y-%m-%d");
my $t = Time::Piece->strptime($to, "%Y-%m-%d");
my $diff = $t - $f;
return int($diff->days);
}
my $auth;
for(@a) {
chomp;
my $line = $_;
if(/^Author: *([^\<]*) \</) {
($auth)=($1);
$person{$auth}++;
}
elsif(/^CommitDate: (.*)/) {
my $d = $1;
$date{$auth}=$d;
my @active12;
my @active9;
my @active6;
my @active3;
my @activew;
foreach my $p (keys %person) {
my $de = delta($date{$p}, $d);
push @active12, $p if($de < 120);
push @active9, $p if($de < 90);
push @active6, $p if($de < 60);
push @active3, $p if($de < 30);
push @activew, $p if($de < 7);
}
if(delta("2010-01-01", $d) < 0) {
# counted, but don't output data from before 2010
next;
}
#printf "$d (%d): %s\n", $#active+1, join(", ", sort @active);
printf "$d;%d;%d;%d;%d;%d\n",
$#active12+1,
$#active9+1,
$#active6+1,
$#active3+1,
$#activew+1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment