Created
July 1, 2010 14:04
-
-
Save jwreagor/460000 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
attr_reader :id | |
lazy_reader :parents | |
lazy_reader :tree | |
lazy_reader :author | |
lazy_reader :authored_date | |
lazy_reader :committer | |
lazy_reader :committed_date | |
lazy_reader :message | |
lazy_reader :short_message | |
lazy_reader :author_string | |
# Instantiate a new Commit | |
# +id+ is the id of the commit | |
# +parents+ is an array of commit ids (will be converted into Commit instances) | |
# +tree+ is the correspdonding tree id (will be converted into a Tree object) | |
# +author+ is the author string | |
# +authored_date+ is the authored Time | |
# +committer+ is the committer string | |
# +committed_date+ is the committed Time | |
# +message+ is an array of commit message lines | |
# | |
# Returns Grit::Commit (baked) | |
def initialize(repo, id, parents, tree, author, authored_date, committer, committed_date, message) | |
@repo = repo | |
@id = id | |
@parents = parents.map { |p| Commit.create(repo, :id => p) } | |
@tree = Tree.create(repo, :id => tree) | |
@author = author | |
@authored_date = authored_date | |
@committer = committer | |
@committed_date = committed_date | |
@message = message.join("\n") | |
@short_message = message.select { |x| !x.strip.empty? }[0] || '' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment