Created
December 20, 2009 05:38
-
-
Save zilkey/260362 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
class Commit < Struct.new(:path) | |
class << self | |
def all | |
commits = `git log --decorate --pretty=oneline` | |
[].tap do |refs| | |
commits.split(/\n/).each do |commit| | |
refs << Commit.new(commit) | |
end | |
end | |
end | |
end | |
def sha | |
path.split(" ").first | |
end | |
def branch | |
path.split(" ").last | |
end | |
def refs | |
path.scan(/\((.*)\)/).flatten.first.split(", ") | |
end | |
end | |
Commit.all.each do |commit| | |
p commit.sha | |
p commit.branch | |
commit.refs.each do |other| | |
puts " %s" % other | |
end | |
puts " " | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment