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 author.
-
#author_date ⇒ Time
Returns the author date.
-
#commit? ⇒ Boolean
Returns whether this object is a commit.
-
#committer
git author.
-
#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 author
442 443 444 445 |
# File 'lib/git/object.rb', line 442 def check_commit @author end |
#author_date ⇒ Time
Returns the author date
451 452 453 |
# File 'lib/git/object.rb', line 451 def .date end |
#commit? ⇒ Boolean
Returns whether this object is a commit
513 514 515 |
# File 'lib/git/object.rb', line 513 def commit? true end |
#committer
git author
456 457 458 459 |
# File 'lib/git/object.rb', line 456 def committer check_commit @committer end |
#committer_date ⇒ Time Also known as: date
Returns the committer date
465 466 467 |
# File 'lib/git/object.rb', line 465 def committer_date committer.date end |
#diff_parent ⇒ Git::Diff
Returns the diff between this commit and its first parent
474 475 476 |
# File 'lib/git/object.rb', line 474 def diff_parent diff(parent) end |
#from_data(data)
This method returns an undefined value.
Loads parsed commit data into this commit object
500 501 502 503 504 505 506 507 |
# 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 |
#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
486 487 488 489 490 491 492 |
# 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 a future version. ' \ 'Use #from_data instead.' ) from_data(data) end |