Class: Git::TagInfo

Inherits:
Data
  • Object
show all
Defined in:
lib/git/tag_info.rb

Overview

Value object representing tag metadata from git tag output

This is a lightweight, immutable data structure returned by tag listing commands. It contains only the data parsed from git output without any repository context or operations.

Examples:

Annotated tag

info = Git::TagInfo.new(
  name: 'v1.0.0',
  oid: 'abc123def456',        # tag object's ID
  target_oid: 'def456abc789', # commit it points to
  objecttype: 'tag',
  tagger_name: 'John Doe',
  tagger_email: '<john@example.com>',
  tagger_date: '2024-01-15T10:30:00-08:00',
  message: 'Release version 1.0.0'
)
info.annotated?   #=> true
info.tagger.name  #=> 'John Doe'

Lightweight tag

info = Git::TagInfo.new(
  name: 'v1.0.0',
  oid: nil,                   # no tag object exists
  target_oid: 'def456abc789', # commit ID
  objecttype: 'commit',
  tagger_name: nil,
  tagger_email: nil,
  tagger_date: nil,
  message: nil
)
info.lightweight?  #=> true
info.tagger        #=> nil

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message

Returns:

  • (Object)

    the current value of message



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/git/tag_info.rb', line 79

TagInfo = Data.define(:name, :oid, :target_oid, :objecttype, :tagger_name, :tagger_email, :tagger_date, :message) do
  # @return [Boolean] true if this is an annotated tag (oid is present)
  def annotated?
    !oid.nil?
  end

  # @return [Boolean] true if this is a lightweight tag (oid is nil)
  def lightweight?
    oid.nil?
  end

  # Return the tagger as an Author object
  #
  # @return [Git::Author, nil] the tagger as an Author object, or nil for lightweight tags
  def tagger
    return nil unless annotated? && tagger_name && tagger_email

    # Git::Author expects format "Name <email> timestamp timezone"
    # We construct a minimal format that will parse correctly
    author = Git::Author.new('')
    author.name = tagger_name
    # Remove angle brackets if present
    author.email = tagger_email.gsub(/\A<|>\z/, '')
    author
  end
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/git/tag_info.rb', line 79

TagInfo = Data.define(:name, :oid, :target_oid, :objecttype, :tagger_name, :tagger_email, :tagger_date, :message) do
  # @return [Boolean] true if this is an annotated tag (oid is present)
  def annotated?
    !oid.nil?
  end

  # @return [Boolean] true if this is a lightweight tag (oid is nil)
  def lightweight?
    oid.nil?
  end

  # Return the tagger as an Author object
  #
  # @return [Git::Author, nil] the tagger as an Author object, or nil for lightweight tags
  def tagger
    return nil unless annotated? && tagger_name && tagger_email

    # Git::Author expects format "Name <email> timestamp timezone"
    # We construct a minimal format that will parse correctly
    author = Git::Author.new('')
    author.name = tagger_name
    # Remove angle brackets if present
    author.email = tagger_email.gsub(/\A<|>\z/, '')
    author
  end
end

#objecttypeObject (readonly)

Returns the value of attribute objecttype

Returns:

  • (Object)

    the current value of objecttype



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/git/tag_info.rb', line 79

TagInfo = Data.define(:name, :oid, :target_oid, :objecttype, :tagger_name, :tagger_email, :tagger_date, :message) do
  # @return [Boolean] true if this is an annotated tag (oid is present)
  def annotated?
    !oid.nil?
  end

  # @return [Boolean] true if this is a lightweight tag (oid is nil)
  def lightweight?
    oid.nil?
  end

  # Return the tagger as an Author object
  #
  # @return [Git::Author, nil] the tagger as an Author object, or nil for lightweight tags
  def tagger
    return nil unless annotated? && tagger_name && tagger_email

    # Git::Author expects format "Name <email> timestamp timezone"
    # We construct a minimal format that will parse correctly
    author = Git::Author.new('')
    author.name = tagger_name
    # Remove angle brackets if present
    author.email = tagger_email.gsub(/\A<|>\z/, '')
    author
  end
end

#oidObject (readonly)

Returns the value of attribute oid

Returns:

  • (Object)

    the current value of oid



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/git/tag_info.rb', line 79

TagInfo = Data.define(:name, :oid, :target_oid, :objecttype, :tagger_name, :tagger_email, :tagger_date, :message) do
  # @return [Boolean] true if this is an annotated tag (oid is present)
  def annotated?
    !oid.nil?
  end

  # @return [Boolean] true if this is a lightweight tag (oid is nil)
  def lightweight?
    oid.nil?
  end

  # Return the tagger as an Author object
  #
  # @return [Git::Author, nil] the tagger as an Author object, or nil for lightweight tags
  def tagger
    return nil unless annotated? && tagger_name && tagger_email

    # Git::Author expects format "Name <email> timestamp timezone"
    # We construct a minimal format that will parse correctly
    author = Git::Author.new('')
    author.name = tagger_name
    # Remove angle brackets if present
    author.email = tagger_email.gsub(/\A<|>\z/, '')
    author
  end
end

#tagger_dateObject (readonly)

Returns the value of attribute tagger_date

Returns:

  • (Object)

    the current value of tagger_date



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/git/tag_info.rb', line 79

TagInfo = Data.define(:name, :oid, :target_oid, :objecttype, :tagger_name, :tagger_email, :tagger_date, :message) do
  # @return [Boolean] true if this is an annotated tag (oid is present)
  def annotated?
    !oid.nil?
  end

  # @return [Boolean] true if this is a lightweight tag (oid is nil)
  def lightweight?
    oid.nil?
  end

  # Return the tagger as an Author object
  #
  # @return [Git::Author, nil] the tagger as an Author object, or nil for lightweight tags
  def tagger
    return nil unless annotated? && tagger_name && tagger_email

    # Git::Author expects format "Name <email> timestamp timezone"
    # We construct a minimal format that will parse correctly
    author = Git::Author.new('')
    author.name = tagger_name
    # Remove angle brackets if present
    author.email = tagger_email.gsub(/\A<|>\z/, '')
    author
  end
end

#tagger_emailObject (readonly)

Returns the value of attribute tagger_email

Returns:

  • (Object)

    the current value of tagger_email



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/git/tag_info.rb', line 79

TagInfo = Data.define(:name, :oid, :target_oid, :objecttype, :tagger_name, :tagger_email, :tagger_date, :message) do
  # @return [Boolean] true if this is an annotated tag (oid is present)
  def annotated?
    !oid.nil?
  end

  # @return [Boolean] true if this is a lightweight tag (oid is nil)
  def lightweight?
    oid.nil?
  end

  # Return the tagger as an Author object
  #
  # @return [Git::Author, nil] the tagger as an Author object, or nil for lightweight tags
  def tagger
    return nil unless annotated? && tagger_name && tagger_email

    # Git::Author expects format "Name <email> timestamp timezone"
    # We construct a minimal format that will parse correctly
    author = Git::Author.new('')
    author.name = tagger_name
    # Remove angle brackets if present
    author.email = tagger_email.gsub(/\A<|>\z/, '')
    author
  end
end

#tagger_nameObject (readonly)

Returns the value of attribute tagger_name

Returns:

  • (Object)

    the current value of tagger_name



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/git/tag_info.rb', line 79

TagInfo = Data.define(:name, :oid, :target_oid, :objecttype, :tagger_name, :tagger_email, :tagger_date, :message) do
  # @return [Boolean] true if this is an annotated tag (oid is present)
  def annotated?
    !oid.nil?
  end

  # @return [Boolean] true if this is a lightweight tag (oid is nil)
  def lightweight?
    oid.nil?
  end

  # Return the tagger as an Author object
  #
  # @return [Git::Author, nil] the tagger as an Author object, or nil for lightweight tags
  def tagger
    return nil unless annotated? && tagger_name && tagger_email

    # Git::Author expects format "Name <email> timestamp timezone"
    # We construct a minimal format that will parse correctly
    author = Git::Author.new('')
    author.name = tagger_name
    # Remove angle brackets if present
    author.email = tagger_email.gsub(/\A<|>\z/, '')
    author
  end
end

#target_oidObject (readonly)

Returns the value of attribute target_oid

Returns:

  • (Object)

    the current value of target_oid



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/git/tag_info.rb', line 79

TagInfo = Data.define(:name, :oid, :target_oid, :objecttype, :tagger_name, :tagger_email, :tagger_date, :message) do
  # @return [Boolean] true if this is an annotated tag (oid is present)
  def annotated?
    !oid.nil?
  end

  # @return [Boolean] true if this is a lightweight tag (oid is nil)
  def lightweight?
    oid.nil?
  end

  # Return the tagger as an Author object
  #
  # @return [Git::Author, nil] the tagger as an Author object, or nil for lightweight tags
  def tagger
    return nil unless annotated? && tagger_name && tagger_email

    # Git::Author expects format "Name <email> timestamp timezone"
    # We construct a minimal format that will parse correctly
    author = Git::Author.new('')
    author.name = tagger_name
    # Remove angle brackets if present
    author.email = tagger_email.gsub(/\A<|>\z/, '')
    author
  end
end

Instance Method Details

#annotated?Boolean

Returns true if this is an annotated tag (oid is present).

Returns:

  • (Boolean)

    true if this is an annotated tag (oid is present)



81
82
83
# File 'lib/git/tag_info.rb', line 81

def annotated?
  !oid.nil?
end

#lightweight?Boolean

Returns true if this is a lightweight tag (oid is nil).

Returns:

  • (Boolean)

    true if this is a lightweight tag (oid is nil)



86
87
88
# File 'lib/git/tag_info.rb', line 86

def lightweight?
  oid.nil?
end

#taggerGit::Author?

Return the tagger as an Author object

Returns:

  • (Git::Author, nil)

    the tagger as an Author object, or nil for lightweight tags



93
94
95
96
97
98
99
100
101
102
103
# File 'lib/git/tag_info.rb', line 93

def tagger
  return nil unless annotated? && tagger_name && tagger_email

  # Git::Author expects format "Name <email> timestamp timezone"
  # We construct a minimal format that will parse correctly
  author = Git::Author.new('')
  author.name = tagger_name
  # Remove angle brackets if present
  author.email = tagger_email.gsub(/\A<|>\z/, '')
  author
end