summary refs log tree commit diff
path: root/bin/git-blame-stats
diff options
context:
space:
mode:
authorFranck Cuny <franck@lumberjaph.net>2015-07-06 11:46:36 -0700
committerFranck Cuny <franck@lumberjaph.net>2015-07-06 11:46:36 -0700
commit3d10fafdfc888b43d91aebf45cb6022f4f3c3203 (patch)
tree61bd8c8475beaa5f86f2e78d1e4d3b7ea625eb84 /bin/git-blame-stats
parentcreate repository (diff)
downloademacs.d-3d10fafdfc888b43d91aebf45cb6022f4f3c3203.tar.gz
configuration files
Diffstat (limited to 'bin/git-blame-stats')
-rwxr-xr-xbin/git-blame-stats37
1 files changed, 37 insertions, 0 deletions
diff --git a/bin/git-blame-stats b/bin/git-blame-stats
new file mode 100755
index 0000000..4f83cba
--- /dev/null
+++ b/bin/git-blame-stats
@@ -0,0 +1,37 @@
+#!/usr/bin/perl
+
+use Getopt::Long;
+use POSIX qw(ceil);
+use strict;
+Getopt::Long::Configure(qw(bundling));
+my %authors;
+my $total;
+my $files;
+my $rev = shift(@ARGV) || "HEAD";
+
+foreach my $file (`git ls-tree --name-only -r $rev`) {
+  chomp($file);
+  print STDERR "Processing $file\n";
+  foreach my $line (`git blame -M -w $rev -- "$file"`) {
+    chomp($line);
+    if (substr($line, 0, 1) eq "^") {
+      ++$authors{"*initial checkin"};
+    } else {
+      $line =~ s[^.*?\((.*?)\s*\d{4}-\d{2}-\d{2}.*][$1];
+      ++$authors{$line};
+    }
+    ++$total;
+  }
+}
+
+print "Total lines: $total\n";
+my $i = 0;
+my $author_ind = ceil(log(scalar(keys %authors)) / log(10));
+my $lines_ind  = ceil(log($total) / log(10));
+foreach my $author (sort { $authors{$b} <=> $authors{$a} } keys %authors) {
+  printf "%${author_ind}s  %${lines_ind}u  %5.2f%%  %s\n",
+  sprintf("#%u", ++$i),
+  $authors{$author},
+  $authors{$author} * 100 / $total,
+  $author;
+}