Class: Dependabot::GithubActions::UpdateChecker::LatestVersionFinder

Inherits:
Package::PackageLatestVersionFinder
  • Object
show all
Extended by:
T::Sig
Includes:
Dependabot::GitCooldownDateResolver
Defined in:
lib/dependabot/github_actions/update_checker/latest_version_finder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dependency:, dependency_files:, credentials:, ignored_versions:, security_advisories:, raise_on_ignored:, options: {}, cooldown_options: nil, git_metadata_fetcher: nil) ⇒ LatestVersionFinder

Returns a new instance of LatestVersionFinder.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/dependabot/github_actions/update_checker/latest_version_finder.rb', line 39

def initialize(
  dependency:,
  dependency_files:,
  credentials:,
  ignored_versions:,
  security_advisories:,
  raise_on_ignored:,
  options: {},
  cooldown_options: nil,
  git_metadata_fetcher: nil
)
  @dependency          = dependency
  @dependency_files    = dependency_files
  @credentials         = credentials
  @ignored_versions    = ignored_versions
  @security_advisories = security_advisories
  @raise_on_ignored    = raise_on_ignored
  @options             = options
  @cooldown_options = cooldown_options
  @git_metadata_fetcher = 

  @git_helper = T.let(git_helper, Dependabot::GithubActions::Helpers::Githelper)
  super(
    dependency: dependency,
    dependency_files: dependency_files,
    credentials: credentials,
    ignored_versions: ignored_versions,
    security_advisories: security_advisories,
    raise_on_ignored: raise_on_ignored,
    options: options,
    cooldown_options: cooldown_options
  )
end

Instance Attribute Details

#cooldown_optionsObject (readonly)

Returns the value of attribute cooldown_options.



80
81
82
# File 'lib/dependabot/github_actions/update_checker/latest_version_finder.rb', line 80

def cooldown_options
  @cooldown_options
end

#credentialsObject (readonly)

Returns the value of attribute credentials.



77
78
79
# File 'lib/dependabot/github_actions/update_checker/latest_version_finder.rb', line 77

def credentials
  @credentials
end

#dependencyObject (readonly)

Returns the value of attribute dependency.



74
75
76
# File 'lib/dependabot/github_actions/update_checker/latest_version_finder.rb', line 74

def dependency
  @dependency
end

#ignored_versionsObject (readonly)

Returns the value of attribute ignored_versions.



83
84
85
# File 'lib/dependabot/github_actions/update_checker/latest_version_finder.rb', line 83

def ignored_versions
  @ignored_versions
end

#raise_on_ignoredObject (readonly)

Returns the value of attribute raise_on_ignored.



89
90
91
# File 'lib/dependabot/github_actions/update_checker/latest_version_finder.rb', line 89

def raise_on_ignored
  @raise_on_ignored
end

#security_advisoriesObject (readonly)

Returns the value of attribute security_advisories.



86
87
88
# File 'lib/dependabot/github_actions/update_checker/latest_version_finder.rb', line 86

def security_advisories
  @security_advisories
end

Instance Method Details

#cooldown_credentialsObject



150
151
152
# File 'lib/dependabot/github_actions/update_checker/latest_version_finder.rb', line 150

def cooldown_credentials
  @credentials
end

#cooldown_source_urlObject



145
146
147
# File 'lib/dependabot/github_actions/update_checker/latest_version_finder.rb', line 145

def cooldown_source_url
  @git_helper.git_commit_checker.dependency_source_details&.url
end

#latest_release_versionObject



95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/dependabot/github_actions/update_checker/latest_version_finder.rb', line 95

def latest_release_version
  release = available_release
  return nil unless release

  Dependabot.logger.info("Available release version/ref is #{release}")

  release = cooldown_filter(release)
  if release.nil?
    Dependabot.logger.info("Returning current version/ref (no viable filtered release) #{current_version}")
    return current_version
  end

  release
end

#latest_version_tagObject



116
117
118
# File 'lib/dependabot/github_actions/update_checker/latest_version_finder.rb', line 116

def latest_version_tag
  available_latest_version_tag
end

#latest_version_tag_respecting_cooldownObject



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/dependabot/github_actions/update_checker/latest_version_finder.rb', line 121

def latest_version_tag_respecting_cooldown
  return @latest_version_tag_respecting_cooldown if defined?(@latest_version_tag_respecting_cooldown)

  @latest_version_tag_respecting_cooldown = T.let(
    begin
      selected_release = latest_release_version
      if selected_release.nil? || selected_release.is_a?(String)
        nil
      else
        latest_tag = available_latest_version_tag
        if latest_tag&.fetch(:version) == selected_release
          latest_tag
        else
          T.must(package_details_fetcher)
           .allowed_version_tags_with_release_dates
           .find { |tag_hash| tag_hash.fetch(:version) == selected_release }
        end
      end
    end,
    T.nilable(T::Hash[Symbol, T.untyped])
  )
end

#lowest_security_fix_releaseObject



111
112
113
# File 'lib/dependabot/github_actions/update_checker/latest_version_finder.rb', line 111

def lowest_security_fix_release
  available_security_fix_releases
end

#package_detailsObject



92
# File 'lib/dependabot/github_actions/update_checker/latest_version_finder.rb', line 92

def package_details; end