Class: Git::Object::Tag

Inherits:
AbstractObject show all
Defined in:
lib/git/object.rb

Overview

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.

Instance Attribute Summary collapse

Attributes inherited from AbstractObject

#mode, #objectish, #size, #type

Instance Method Summary collapse

Methods inherited from AbstractObject

#archive, #blob?, #commit?, #contents, #contents_array, #diff, #grep, #log, #sha, #to_s, #tree?

Constructor Details

#initialize(base, name) ⇒ Tag #initialize(base, sha, name) ⇒ Tag

Returns a new instance of Tag.



554
555
556
557
558
559
560
561
562
563
564
565
566
# 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

Instance Attribute Details

#nameString



538
539
540
# File 'lib/git/object.rb', line 538

def name
  @name
end

Instance Method Details

#annotated?Boolean

Returns whether this tag is annotated



572
573
574
# File 'lib/git/object.rb', line 572

def annotated?
  @annotated = @annotated.nil? ? (object_repository.cat_file_type(name) == 'tag') : @annotated
end

#messageString?

Returns the tag message



581
582
583
584
# File 'lib/git/object.rb', line 581

def message
  check_tag
  @message
end

#tag?Boolean

Returns whether this object is a tag



590
591
592
# File 'lib/git/object.rb', line 590

def tag?
  true
end

#taggerGit::Author?

Returns the tagger identity



599
600
601
602
# File 'lib/git/object.rb', line 599

def tagger
  check_tag
  @tagger
end