Skip to content

Instantly share code, notes, and snippets.

@patmaddox
Created January 13, 2009 05:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patmaddox/46333 to your computer and use it in GitHub Desktop.
Save patmaddox/46333 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'grit'
require 'gruff'
module GotGit
class Repo
def initialize(url)
@repo = Grit::Repo.new url
end
def authors
return @authors if @authors
author_hash = {}
@repo.each_commit do |commit|
author_hash[commit.author.name] ||= 0
author_hash[commit.author.name] += 1
end
@authors = author_hash.sort_by {|k, v| v }.reverse
end
def plot(filename)
g = Gruff::Bar.new
g.title = "Contributors"
g.hide_legend = true
authors.each {|a| g.data a.first, a.last }
g.write filename
end
end
end
module Grit
class Repo
def each_commit(branch='master', &block)
offset = 0
max = 1000
while !(this_group = commits(branch, max, max * offset)).empty? do
this_group.each {|c| block.call(c) }
offset += 1
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment