Created
January 13, 2009 05:04
-
-
Save patmaddox/46333 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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