Skip to content

Instantly share code, notes, and snippets.

@zilkey
Created December 20, 2009 05:38
Show Gist options
  • Save zilkey/260362 to your computer and use it in GitHub Desktop.
Save zilkey/260362 to your computer and use it in GitHub Desktop.
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