Class: Git::Object::Commit
- Inherits:
-
AbstractObject
- Object
- AbstractObject
- Git::Object::Commit
- Defined in:
- lib/git/object.rb
Overview
A Git commit object
Instance Attribute Summary
Attributes inherited from AbstractObject
#mode, #objectish, #size, #type
Instance Method Summary collapse
-
#author ⇒ Git::AuthorInfo
Returns the commit author identity.
-
#author_date ⇒ Time
Returns the author date.
-
#commit? ⇒ Boolean
Returns whether this object is a commit.
-
#committer ⇒ Git::AuthorInfo
Returns the commit committer identity.
-
#committer_date ⇒ Time
(also: #date)
Returns the committer date.
-
#diff_parent ⇒ Git::Diff
Returns the diff between this commit and its first parent.
-
#from_data(data)
Loads parsed commit data into this commit object.
-
#gtree ⇒ Git::Object::Tree
Returns the tree for this commit.
-
#initialize(base, sha, init = nil) ⇒ Commit
constructor
Creates a commit object wrapper.
-
#message ⇒ String
Returns the commit message.
-
#name ⇒ String
Returns the symbolic name for this commit.
-
#parent ⇒ Git::Object::Commit?
Returns the first parent commit.
-
#parents
array of all parent commits.
-
#set_commit(data)
deprecated
Deprecated.
use #from_data instead
Methods inherited from AbstractObject
#archive, #blob?, #contents, #contents_array, #diff, #grep, #log, #sha, #tag?, #to_s, #tree?
Constructor Details
#initialize(base, sha, init = nil) ⇒ Commit
Creates a commit object wrapper
388 389 390 391 392 393 394 395 396 397 398 |
# 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 |
Instance Method Details
#author ⇒ Git::AuthorInfo
Returns the commit author identity
445 446 447 448 |
# File 'lib/git/object.rb', line 445 def check_commit @author end |
#author_date ⇒ Time
Returns the author date
454 455 456 |
# File 'lib/git/object.rb', line 454 def .date end |
#commit? ⇒ Boolean
Returns whether this object is a commit
519 520 521 |
# File 'lib/git/object.rb', line 519 def commit? true end |
#committer ⇒ Git::AuthorInfo
Returns the commit committer identity
462 463 464 465 |
# File 'lib/git/object.rb', line 462 def committer check_commit @committer end |
#committer_date ⇒ Time Also known as: date
Returns the committer date
471 472 473 |
# File 'lib/git/object.rb', line 471 def committer_date committer.date end |
#diff_parent ⇒ Git::Diff
Returns the diff between this commit and its first parent
480 481 482 |
# File 'lib/git/object.rb', line 480 def diff_parent diff(parent) end |
#from_data(data)
This method returns an undefined value.
Loads parsed commit data into this commit object
506 507 508 509 510 511 512 513 |
# File 'lib/git/object.rb', line 506 def from_data(data) @sha ||= data['sha'] @committer = Git::AuthorInfo.parse(data['committer']) @author = Git::AuthorInfo.parse(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 |
#gtree ⇒ Git::Object::Tree
Returns the tree for this commit
421 422 423 424 |
# File 'lib/git/object.rb', line 421 def gtree check_commit Tree.new(@base, @tree) end |
#message ⇒ String
Returns the commit message
404 405 406 407 |
# File 'lib/git/object.rb', line 404 def check_commit @message end |
#name ⇒ String
Returns the symbolic name for this commit
413 414 415 |
# File 'lib/git/object.rb', line 413 def name object_repository.name_rev(sha) end |
#parent ⇒ Git::Object::Commit?
Returns the first parent commit
431 432 433 |
# File 'lib/git/object.rb', line 431 def parent parents.first end |
#parents
array of all parent commits
436 437 438 439 |
# File 'lib/git/object.rb', line 436 def parents check_commit @parents end |
#set_commit(data)
use #from_data instead
This method returns an undefined value.
Sets parsed commit data on this commit object
492 493 494 495 496 497 498 |
# File 'lib/git/object.rb', line 492 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 |