Permalink
Browse files

git-stats by coderifous

  • Loading branch information...
rmm5t committed Nov 1, 2010
1 parent dce3e49 commit bb590a3f247784ba547f316e07ed2ad2a45297e0
Showing with 25 additions and 0 deletions.
  1. +25 −0 git-stats
View
@@ -0,0 +1,25 @@
+#!/usr/bin/env ruby
+
+# Borrowed from Jim Garvin
+# http://github.com/coderifous/dotfiles/blob/master/bin/git-stats.rb
+
+Authors = []
+Format = "%20s %13s %12s %12s %10s\n"
+printf(Format, *%w(Author files-changed insertions deletions net))
+
+open("| git shortlog -s -n").each do |line|
+ Authors << line.sub(/^\s*\d+\s*/, '').chomp
+end
+
+Authors.each do |name|
+ files_changed = insertions = deletions = 0
+ open("| git log --shortstat --no-merges --author='#{name}' | grep 'files changed'").each do |line|
+ matchdata = line.match(/(\d+) files changed, (\d+) insertions.* (\d+) deletions/)
+ files_changed += matchdata[1].to_i
+ insertions += matchdata[2].to_i
+ deletions += matchdata[3].to_i
+ end
+
+ printf(Format, name, files_changed, insertions, "-#{deletions}", insertions - deletions) unless files_changed == 0
+end
+

0 comments on commit bb590a3

Please sign in to comment.