class Git::Object::AbstractObject::Tag
A Git tag object
This class represents a tag in Git, which can be either annotated or lightweight.
Annotated tags contain additional metadata such as the tagger’s name, email, and the date when the tag was created, along with a message.
Attributes
@return [String] the tag name
Public Class Methods
Source
# File lib/git/object.rb, line 554 def initialize(base, sha, name = nil) if name.nil? name = sha sha = base.tag_sha(name) raise Git::UnexpectedResultError, "Tag '#{name}' does not exist." if sha == '' end super(base, sha) @name = name @annotated = nil @loaded = false end
@overload initialize(base, name)
@param base [Git::Repository] the git repository @param name [String] the name of the tag
@overload initialize(base, sha, name)
@param base [Git::Repository] the git repository @param sha [String] the SHA of the tag object @param name [String] the name of the tag
Calls superclass method
Git::Object::AbstractObject::new
Public Instance Methods
Source
# File lib/git/object.rb, line 572 def annotated? @annotated = @annotated.nil? ? (object_repository.cat_file_type(name) == 'tag') : @annotated end
Returns whether this tag is annotated
@return [Boolean] ‘true` when the tag has an annotated tag object
Source
# File lib/git/object.rb, line 581 def message check_tag @message end
Returns the tag message
@return [String, nil] the annotated tag message, or ‘nil` for a
lightweight tag
Source
# File lib/git/object.rb, line 590 def tag? true end
Returns whether this object is a tag
@return [Boolean] ‘true`
Source
# File lib/git/object.rb, line 599 def tagger check_tag @tagger end
Returns the tagger identity
@return [Git::Author, nil] the tagger for an annotated tag, or ‘nil`
for a lightweight tag
Private Instance Methods
Source
# File lib/git/object.rb, line 610 def check_tag return if @loaded if annotated? tdata = object_repository.cat_file_tag(@name) @message = tdata['message'].chomp @tagger = Git::Author.new(tdata['tagger']) else @message = @tagger = nil end @loaded = true end
Loads annotated tag data when available
@return [void]