class Git::Object::AbstractObject::Commit
A Git commit object
Public Class Methods
Source
# File lib/git/object.rb, line 388 def initialize(base, sha, init = nil) super(base, sha) @tree = nil @parents = nil @author = nil @committer = nil @message = nil return unless init from_data(init) end
Creates a commit object wrapper
@param base [Git::Repository] the repository used to query object data
@param sha [String] the commit SHA or object expression
@param init [Hash, nil] parsed commit data used to initialize eagerly
Git::Object::AbstractObject::new
Public Instance Methods
Source
# File lib/git/object.rb, line 513 def commit? true end
Returns whether this object is a commit
@return [Boolean] ‘true`
Source
# File lib/git/object.rb, line 456 def committer check_commit @committer end
git author
Source
# File lib/git/object.rb, line 465 def committer_date committer.date end
Returns the committer date
@return [Time] the committer timestamp
Source
# File lib/git/object.rb, line 474 def diff_parent diff(parent) end
Returns the diff between this commit and its first parent
@return [Git::Diff] the diff from the first parent to this commit
Source
# File lib/git/object.rb, line 500 def from_data(data) @sha ||= data['sha'] @committer = Git::Author.new(data['committer']) @author = Git::Author.new(data['author']) @tree = Git::Object::Tree.new(@base, data['tree']) @parents = data['parent'].map { |sha| Git::Object::Commit.new(@base, sha) } @message = data['message'].chomp end
Loads parsed commit data into this commit object
@param data [Hash] parsed commit data from ‘git cat-file commit`
@return [void]
Source
# File lib/git/object.rb, line 421 def gtree check_commit Tree.new(@base, @tree) end
Returns the tree for this commit
@return [Git::Object::Tree] the commit tree
Source
# File lib/git/object.rb, line 404 def message check_commit @message end
Returns the commit message
@return [String] the commit message without the trailing newline
Source
# File lib/git/object.rb, line 413 def name object_repository.name_rev(sha) end
Returns the symbolic name for this commit
@return [String] the name produced by ‘git name-rev`
Source
# File lib/git/object.rb, line 431 def parent parents.first end
Returns the first parent commit
@return [Git::Object::Commit, nil] the first parent commit, or ‘nil`
for a root commit
Source
# File lib/git/object.rb, line 436 def parents check_commit @parents end
array of all parent commits
Source
# File lib/git/object.rb, line 486 def set_commit(data) # rubocop:disable Naming/AccessorMethodName Git::Deprecation.warn( 'Git::Object::Commit#set_commit is deprecated and will be removed in v6.0.0. ' \ 'Use #from_data instead.' ) from_data(data) end
Sets parsed commit data on this commit object
@param data [Hash] parsed commit data
@return [void]
@deprecated use {#from_data} instead
Private Instance Methods
Source
# File lib/git/object.rb, line 520 def check_commit return if @tree data = object_repository.cat_file_commit(@objectish) from_data(data) end
see if this object has been initialized and do so if not