Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

git-stats by coderifous

  • Loading branch information...
commit bb590a3f247784ba547f316e07ed2ad2a45297e0 1 parent dce3e49
@rmm5t authored
Showing with 25 additions and 0 deletions.
  1. +25 −0 git-stats
View
25 git-stats
@@ -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
+
Please sign in to comment.
Something went wrong with that request. Please try again.