Class: Dependabot::MetadataFinders::Base::ReleaseFinder

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/metadata_finders/base/release_finder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source:, dependency:, credentials:) ⇒ ReleaseFinder

Returns a new instance of ReleaseFinder.



66
67
68
69
70
# File 'lib/dependabot/metadata_finders/base/release_finder.rb', line 66

def initialize(source:, dependency:, credentials:)
  @source = source
  @dependency = dependency
  @credentials = credentials
end

Instance Attribute Details

#credentialsObject (readonly)

Returns the value of attribute credentials.



53
54
55
# File 'lib/dependabot/metadata_finders/base/release_finder.rb', line 53

def credentials
  @credentials
end

#dependencyObject (readonly)

Returns the value of attribute dependency.



50
51
52
# File 'lib/dependabot/metadata_finders/base/release_finder.rb', line 50

def dependency
  @dependency
end

#sourceObject (readonly)

Returns the value of attribute source.



56
57
58
# File 'lib/dependabot/metadata_finders/base/release_finder.rb', line 56

def source
  @source
end

Instance Method Details

#releases_textObject



92
93
94
95
96
97
# File 'lib/dependabot/metadata_finders/base/release_finder.rb', line 92

def releases_text
  return unless relevant_releases&.any?
  return if relevant_releases&.all? { |r| r.body.nil? || r.body == "" }

  relevant_releases&.map { |r| serialize_release(r) }&.join("\n\n")
end

#releases_urlObject



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/dependabot/metadata_finders/base/release_finder.rb', line 73

def releases_url
  return unless source

  # Azure does not provide tags via API, so we can't check whether
  # there are any releases. So, optimistically return the tags location
  return "#{T.must(source).url}/tags" if T.must(source).provider == "azure"

  # If there are no releases, we won't be linking to the releases page
  return unless all_releases.any?

  case T.must(source).provider
  when "github" then "#{T.must(source).url}/releases"
  when "gitlab" then "#{T.must(source).url}/tags"
  when "bitbucket", "codecommit" then nil
  else raise "Unexpected repo provider '#{T.must(source).provider}'"
  end
end