Class: Dependabot::GitTagDetails

Inherits:
Hash
  • Object
show all
Extended by:
T::Generic, T::Sig
Defined in:
lib/dependabot/git_tag_details.rb

Overview

A git tag (or ref) resolved to a version, as produced by GitCommitChecker's local_tag_for_* / local_ref_for_* methods, e.g.:

{
tag: "v1.2.0",
version: Dependabot::Version.new("1.2.0"),
commit_sha: "a1b2c3...",
tag_sha: "d4e5f6..." # nil for lightweight tags
}

Distinct from Dependabot::GitTagWithDetail, which carries a tag name and release date for cooldown handling.

Subclasses Hash so it is a drop-in replacement at the many call sites that read entries with [:key] / fetch, while exposing typed readers for the well-known keys. Instances compare equal (Hash#==) to plain hashes with the same content, so existing comparisons and API payloads are unaffected.

Constant Summary collapse

K =
type_member { { fixed: Symbol } }
V =
type_member { { fixed: Object } }
Elem =
type_member { { fixed: [Symbol, Object] } }

Instance Method Summary collapse

Constructor Details

#initialize(tag:, version: nil, commit_sha: nil, tag_sha: nil) ⇒ GitTagDetails

Returns a new instance of GitTagDetails.



40
41
42
43
44
45
46
# File 'lib/dependabot/git_tag_details.rb', line 40

def initialize(tag:, version: nil, commit_sha: nil, tag_sha: nil)
  super()
  self[:tag] = tag
  self[:version] = version
  self[:commit_sha] = commit_sha
  self[:tag_sha] = tag_sha
end

Instance Method Details

#commit_shaObject



62
63
64
# File 'lib/dependabot/git_tag_details.rb', line 62

def commit_sha
  T.cast(self[:commit_sha], T.nilable(String))
end

#tagObject



50
51
52
# File 'lib/dependabot/git_tag_details.rb', line 50

def tag
  T.cast(self[:tag], String)
end

#tag_shaObject



68
69
70
# File 'lib/dependabot/git_tag_details.rb', line 68

def tag_sha
  T.cast(self[:tag_sha], T.nilable(String))
end

#versionObject



56
57
58
# File 'lib/dependabot/git_tag_details.rb', line 56

def version
  T.cast(self[:version], T.nilable(Gem::Version))
end