Class: Git::TagInfo
- Inherits:
-
Data
- Object
- Data
- Git::TagInfo
- 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.
Instance Attribute Summary collapse
-
#message ⇒ String?
readonly
The tag message, or nil for lightweight tags.
-
#name ⇒ String
readonly
The tag name (e.g., 'v1.0.0').
-
#objecttype ⇒ String
readonly
'tag' for annotated tags, 'commit' for lightweight tags.
-
#oid ⇒ String?
readonly
The object ID of the tag object itself.
-
#tagger_date ⇒ String?
readonly
The tag date in ISO 8601 format, or nil for lightweight tags.
-
#tagger_email ⇒ String?
readonly
The tagger's email, or nil for lightweight tags.
-
#tagger_name ⇒ String?
readonly
The tagger's name, or nil for lightweight tags.
-
#target_oid ⇒ String
readonly
The object ID of the commit this tag ultimately points to.
Instance Method Summary collapse
-
#annotated? ⇒ Boolean
True if this is an annotated tag (oid is present).
-
#lightweight? ⇒ Boolean
True if this is a lightweight tag (oid is nil).
-
#tagger ⇒ Git::Author?
Return the tagger as an Author object.
Instance Attribute Details
#message ⇒ String? (readonly)
Returns the tag message, or nil for lightweight tags.
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 105 |
# File 'lib/git/tag_info.rb', line 80 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 = Git::Author.new('') .name = tagger_name # Remove angle brackets if present .email = tagger_email.gsub(/\A<|>\z/, '') end end |
#name ⇒ String (readonly)
Returns the tag name (e.g., 'v1.0.0').
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 105 |
# File 'lib/git/tag_info.rb', line 80 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 = Git::Author.new('') .name = tagger_name # Remove angle brackets if present .email = tagger_email.gsub(/\A<|>\z/, '') end end |
#objecttype ⇒ String (readonly)
Returns 'tag' for annotated tags, 'commit' for lightweight tags.
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 105 |
# File 'lib/git/tag_info.rb', line 80 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 = Git::Author.new('') .name = tagger_name # Remove angle brackets if present .email = tagger_email.gsub(/\A<|>\z/, '') end end |
#oid ⇒ String? (readonly)
The object ID of the tag object itself.
For annotated tags, this is the tag object's ID. For lightweight tags, this is nil because lightweight tags are not objects in the git database.
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 105 |
# File 'lib/git/tag_info.rb', line 80 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 = Git::Author.new('') .name = tagger_name # Remove angle brackets if present .email = tagger_email.gsub(/\A<|>\z/, '') end end |
#tagger_date ⇒ String? (readonly)
Returns the tag date in ISO 8601 format, or nil for lightweight tags.
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 105 |
# File 'lib/git/tag_info.rb', line 80 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 = Git::Author.new('') .name = tagger_name # Remove angle brackets if present .email = tagger_email.gsub(/\A<|>\z/, '') end end |
#tagger_email ⇒ String? (readonly)
Returns the tagger's email, or nil for lightweight tags.
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 105 |
# File 'lib/git/tag_info.rb', line 80 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 = Git::Author.new('') .name = tagger_name # Remove angle brackets if present .email = tagger_email.gsub(/\A<|>\z/, '') end end |
#tagger_name ⇒ String? (readonly)
Returns the tagger's name, or nil for lightweight tags.
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 105 |
# File 'lib/git/tag_info.rb', line 80 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 = Git::Author.new('') .name = tagger_name # Remove angle brackets if present .email = tagger_email.gsub(/\A<|>\z/, '') end end |
#target_oid ⇒ String (readonly)
The object ID of the commit this tag ultimately points to.
For both annotated and lightweight tags, this is the commit ID that the tag resolves to (i.e., the dereferenced target).
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 105 |
# File 'lib/git/tag_info.rb', line 80 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 = Git::Author.new('') .name = tagger_name # Remove angle brackets if present .email = tagger_email.gsub(/\A<|>\z/, '') end end |
Instance Method Details
#annotated? ⇒ Boolean
Returns true if this is an annotated tag (oid is present).
82 83 84 |
# File 'lib/git/tag_info.rb', line 82 def annotated? !oid.nil? end |
#lightweight? ⇒ Boolean
Returns true if this is a lightweight tag (oid is nil).
87 88 89 |
# File 'lib/git/tag_info.rb', line 87 def lightweight? oid.nil? end |
#tagger ⇒ Git::Author?
Return the tagger as an Author object
94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/git/tag_info.rb', line 94 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 = Git::Author.new('') .name = tagger_name # Remove angle brackets if present .email = tagger_email.gsub(/\A<|>\z/, '') end |