Class: Amp::Core::Repositories::Git::CommitObject

Inherits:
RawObject
  • Object
show all
Defined in:
lib/amp-git/repo_format/commit_object.rb

Overview

CommitObject

This is a commit object in the git system. This contains a reference to a tree, one or more parents, an author, a committer, and a message. This object is all you need to know everything about a commit.

Constant Summary

Constants inherited from RawObject

RawObject::AUTHOR_MATCH

Instance Attribute Summary collapse

Attributes inherited from RawObject

#content, #hash_id, #type

Instance Method Summary collapse

Methods inherited from RawObject

construct, for_hash

Constructor Details

#initialize(hsh, opener, content = nil) ⇒ CommitObject

Initializes the CommitObject. Needs a hash to identify it and an opener. The opener should point to the .git directory. Immediately parses the object.

Parameters:

  • hsh (String)

    the hash to use to find the object

  • opener (Support::RootedOpener)

    the opener to use to open the object file

  • content (String) (defaults to: nil)

    if the content is known already, use the provided content instead



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/amp-git/repo_format/commit_object.rb', line 44

def initialize(hsh, opener, content = nil)
  if content
    @hash_id, @opener = hsh, opener
    @type = 'commit'
    @content = content
  else
    super(hsh, opener)
  end
  @parent_refs = []
  parse!
end

Instance Attribute Details

#authorObject (readonly)

Returns the value of attribute author.



32
33
34
# File 'lib/amp-git/repo_format/commit_object.rb', line 32

def author
  @author
end

#committerObject (readonly)

Returns the value of attribute committer.



32
33
34
# File 'lib/amp-git/repo_format/commit_object.rb', line 32

def committer
  @committer
end

#dateObject (readonly)

Returns the value of attribute date.



32
33
34
# File 'lib/amp-git/repo_format/commit_object.rb', line 32

def date
  @date
end

#messageObject (readonly)

Returns the value of attribute message.



32
33
34
# File 'lib/amp-git/repo_format/commit_object.rb', line 32

def message
  @message
end

#parent_refsObject (readonly)

Returns the value of attribute parent_refs.



32
33
34
# File 'lib/amp-git/repo_format/commit_object.rb', line 32

def parent_refs
  @parent_refs
end

#tree_refObject (readonly)

Returns the value of attribute tree_ref.



32
33
34
# File 'lib/amp-git/repo_format/commit_object.rb', line 32

def tree_ref
  @tree_ref
end