Skip to content

Instantly share code, notes, and snippets.

@Aeon
Forked from grosser/README.markdown
Created May 7, 2010 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Aeon/393324 to your computer and use it in GitHub Desktop.
Save Aeon/393324 to your computer and use it in GitHub Desktop.
git-stats

Ever wondered how much who adds/removes, its time to find out :D (those are real stats, i just obfuscated the names )

###Results

Git scores (in LOC):
mr-add              :  +482273       -9466
justu               :  +286250       -159905
grosser             :  +152384       -323344
another             :  +121257       -82116
naames              :  +104577       -13591
justfor             :  +68716        -72446
example             :  +7795         -4987
andeven             :  +5100         -1730
morenow             :  +4225         -2764
finish              :  +17           -19

###Install Copy init git_stats.rb and ruby git_stats.rb (you can add the names of people who commit with different users into the ’same’ array)

#!/usr/bin/env ruby
t = Time.now
#same = [['name-a','name-b'],['mr fred','fred']]
same = []
pipe = open('|git log --pretty=format:"A:%an" --shortstat --no-merges')
author = "unknown"
stats = {}
loop do
line = pipe.readline rescue break
if line =~ /^A\:(.*)$/
author = $1
found = same.detect{|a| a.include?(author)}
author = found.first if found
next
end
if line =~ /files changed, (\d+) insertions\(\+\), (\d+) deletions/
stats[author] ||= Hash.new(0)
stats[author]['+']+=$1.to_i
stats[author]['-']+=$2.to_i
print '.'
end
end
puts "\nGit scores (in LOC):"
puts stats.sort_by{|a,d| -d['+'] }.map{|author, data| "#{author.ljust(20)}: +#{data['+'].to_s.ljust(10)} -#{data['-'].to_s.ljust(10)} " } * "\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment