Skip to content

Commit

Permalink
dev-cmd/bump-formula-pr: clean up unused code
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Cho <[email protected]>
  • Loading branch information
cho-m committed Mar 21, 2024
1 parent be3d164 commit a9eddb7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Library/Homebrew/dev-cmd/bump-formula-pr.rb
Expand Up @@ -471,8 +471,8 @@ def check_new_version(formula, tap_remote_repo, version: nil, url: nil, tag: nil
end

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)

Check warning on line 475 in Library/Homebrew/dev-cmd/bump-formula-pr.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/dev-cmd/bump-formula-pr.rb#L474-L475

Added lines #L474 - L475 were not covered by tests
return if throttled_rate.blank?

formula_suffix = Version.new(new_version).patch.to_i
Expand Down
22 changes: 7 additions & 15 deletions Library/Homebrew/dev-cmd/bump.rb
Expand Up @@ -248,9 +248,7 @@ def skip_ineligible_formulae(formula_or_cask)
end

sig {
params(
formula_or_cask: T.any(Formula, Cask::Cask),
).returns([T.any(Version, String), T.nilable(T.any(Version, String))])
params(formula_or_cask: T.any(Formula, Cask::Cask)).returns(T.any(Version, String))
}
def livecheck_result(formula_or_cask)
name = Livecheck.package_or_resource_name(formula_or_cask)
Expand Down Expand Up @@ -279,29 +277,25 @@ def livecheck_result(formula_or_cask)

if skip_info.present?
return "#{skip_info[:status]}" \
"#{" - #{skip_info[:messages].join(", ")}" if skip_info[:messages].present?}",
nil
"#{" - #{skip_info[:messages].join(", ")}" if skip_info[:messages].present?}"
end

version_info = Livecheck.latest_version(
formula_or_cask,
referenced_formula_or_cask:,
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])
latest_throttled = if !version_info.key?(:latest_throttled)
nil
if !version_info.key?(:latest_throttled)

Check warning on line 290 in Library/Homebrew/dev-cmd/bump.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/dev-cmd/bump.rb#L290

Added line #L290 was not covered by tests
Version.new(version_info[:latest])
elsif version_info[:latest_throttled].nil?
"unable to get throttled versions"
else
Version.new(version_info[:latest_throttled])
end

[latest, latest_throttled]
rescue => e
["error: #{e}", nil]
"error: #{e}"
end

sig {
Expand Down Expand Up @@ -360,9 +354,7 @@ def retrieve_versions_by_arch(formula_or_cask:, repositories:, name:)
current_version_value = Version.new(loaded_formula_or_cask.version)
end

livecheck_latest, livecheck_latest_throttled = 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
livecheck_latest = livecheck_result(loaded_formula_or_cask)

new_version_value = if (livecheck_latest.is_a?(Version) && livecheck_latest >= current_version_value) ||
current_version_value == "latest"
Expand Down

0 comments on commit a9eddb7

Please sign in to comment.