Skip to content

Instantly share code, notes, and snippets.

@schacon
Created July 22, 2010 21:37
Show Gist options
  • Save schacon/486627 to your computer and use it in GitHub Desktop.
Save schacon/486627 to your computer and use it in GitHub Desktop.
used to see how much outside contribution we have from gitstats output
#! /usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require 'pp'
exclude = ["Author", "defunkt", "Chris Wanstrath", "Kyle Neath", "PJ Hyett", "Scott Chacon", "Tom Preston-Werner", "tekkub", "Tekkub", "Ryan Tomayko"]
Dir.glob("*").each do |d|
if !File.file?(d)
puts d
stats = {:authors => 0, :percent => 0.0, :commits => 0, :lines => 0}
a = File.read("#{d}/authors.html")
doc = Nokogiri::HTML(a)
doc.search('table#authors > tr').each do |tr|
author = tr.children.first.content
if !exclude.include?(author)
commits_raw = tr.children[1].content
m = /(\d+) \((.*?)%\)/.match(commits_raw)
stats[:authors] += 1
stats[:commits] += m[1].to_i
stats[:percent] += m[2].to_f
add = tr.children[2].content.to_i
remove = tr.children[3].content.to_i
if (add + remove) < 2000
stats[:lines] += add
stats[:lines] += remove
end
end
end
pp stats
puts "", ""
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment