dev-cmd/bump-formula-pr: clean up unused code

Signed-off-by: Michael Cho <michael@michaelcho.dev>
This commit is contained in:
Michael Cho 2024-03-21 09:12:14 -04:00
parent 0f063921c5
commit 43e2e28869
No known key found for this signature in database
GPG Key ID: 55E85E28A7CD1E85
2 changed files with 9 additions and 17 deletions

View File

@ -471,8 +471,8 @@ module Homebrew
end end
def check_throttle(formula, new_version) def check_throttle(formula, new_version)
throttled_rate = formula.tap.audit_exceptions.dig(:throttled_formulae, formula.name) throttled_rate = formula.livecheck.throttle
throttled_rate ||= formula.livecheck.throttle throttled_rate ||= formula.tap.audit_exceptions.dig(:throttled_formulae, formula.name)
return if throttled_rate.blank? return if throttled_rate.blank?
formula_suffix = Version.new(new_version).patch.to_i formula_suffix = Version.new(new_version).patch.to_i

View File

@ -248,9 +248,7 @@ module Homebrew
end end
sig { sig {
params( params(formula_or_cask: T.any(Formula, Cask::Cask)).returns(T.any(Version, String))
formula_or_cask: T.any(Formula, Cask::Cask),
).returns([T.any(Version, String), T.nilable(T.any(Version, String))])
} }
def livecheck_result(formula_or_cask) def livecheck_result(formula_or_cask)
name = Livecheck.package_or_resource_name(formula_or_cask) name = Livecheck.package_or_resource_name(formula_or_cask)
@ -279,8 +277,7 @@ module Homebrew
if skip_info.present? if skip_info.present?
return "#{skip_info[:status]}" \ return "#{skip_info[:status]}" \
"#{" - #{skip_info[:messages].join(", ")}" if skip_info[:messages].present?}", "#{" - #{skip_info[:messages].join(", ")}" if skip_info[:messages].present?}"
nil
end end
version_info = Livecheck.latest_version( version_info = Livecheck.latest_version(
@ -288,20 +285,17 @@ module Homebrew
referenced_formula_or_cask:, referenced_formula_or_cask:,
json: true, full_name: false, verbose: true, debug: false json: true, full_name: false, verbose: true, debug: false
) )
return "unable to get versions", nil if version_info.blank? return "unable to get versions" if version_info.blank?
latest = Version.new(version_info[:latest]) if !version_info.key?(:latest_throttled)
latest_throttled = if !version_info.key?(:latest_throttled) Version.new(version_info[:latest])
nil
elsif version_info[:latest_throttled].nil? elsif version_info[:latest_throttled].nil?
"unable to get throttled versions" "unable to get throttled versions"
else else
Version.new(version_info[:latest_throttled]) Version.new(version_info[:latest_throttled])
end end
[latest, latest_throttled]
rescue => e rescue => e
["error: #{e}", nil] "error: #{e}"
end end
sig { sig {
@ -360,9 +354,7 @@ module Homebrew
current_version_value = Version.new(loaded_formula_or_cask.version) current_version_value = Version.new(loaded_formula_or_cask.version)
end end
livecheck_latest, livecheck_latest_throttled = livecheck_result(loaded_formula_or_cask) livecheck_latest = livecheck_result(loaded_formula_or_cask)
# TODO: Pass down `livecheck_latest` info to print output for throttled formulae or casks
livecheck_latest = livecheck_latest_throttled if livecheck_latest_throttled
new_version_value = if (livecheck_latest.is_a?(Version) && livecheck_latest >= current_version_value) || new_version_value = if (livecheck_latest.is_a?(Version) && livecheck_latest >= current_version_value) ||
current_version_value == "latest" current_version_value == "latest"