diff options
author | scott Chacon <schacon@agadorsparticus.corp.reactrix.com> | 2007-11-12 17:29:39 -0800 |
---|---|---|
committer | scott Chacon <schacon@agadorsparticus.corp.reactrix.com> | 2007-11-12 17:29:39 -0800 |
commit | 852a0e63d294de874c3311f5e7edf40e2f2ecd60 (patch) | |
tree | b77a38e91156d5e330246a6111f0ee835c38a80b /lib/git/object.rb | |
parent | ec59c5c7ee9fa3b5831ed0b5f713cee218480ea3 (diff) | |
download | third_party-ruby-git-852a0e63d294de874c3311f5e7edf40e2f2ecd60.tar.gz third_party-ruby-git-852a0e63d294de874c3311f5e7edf40e2f2ecd60.tar.xz third_party-ruby-git-852a0e63d294de874c3311f5e7edf40e2f2ecd60.zip |
added a bunch of good stuff to the commit object
Diffstat (limited to 'lib/git/object.rb')
-rw-r--r-- | lib/git/object.rb | 67 |
1 files changed, 66 insertions, 1 deletions
diff --git a/lib/git/object.rb b/lib/git/object.rb index a7d7c17..58ea7ab 100644 --- a/lib/git/object.rb +++ b/lib/git/object.rb @@ -12,7 +12,7 @@ module Git def initialize(base, sha) @base = base - @sha = sha + @sha = sha.to_s @size = @base.lib.object_size(@sha) setup end @@ -63,9 +63,74 @@ module Git end class Commit < AbstractObject + + @tree = nil + @parents = nil + @author = nil + @committer = nil + @message = nil + def setup @type = 'commit' end + + def message + check_commit + @message + end + + def gtree + check_commit + Tree.new(@base, @tree) + end + + def parent + parents.first + end + + # array of all parent commits + def parents + check_commit + @parents + end + + # git author + def author + check_commit + @author + end + + def author_date + author.date + end + + # git author + def committer + check_commit + @committer + end + + def committer_date + committer.date + end + alias_method :date, :committer_date + + def diff_parent + diff(parent) + end + + private + + # see if this object has been initialized and do so if not + def check_commit + data = @base.lib.commit_data(@sha) + @committer = Git::Author.new(data['committer']) + @author = Git::Author.new(data['author']) + @tree = Tree.new(@base, data['tree']) + @parents = data['parent'].map{ |sha| Commit.new(@base, sha) } + @message = data['message'].chomp + end + end class Tag < AbstractObject |