Refactor brew bump: apply suggestions from code review
Co-authored-by: Sam Ford <1584702+samford@users.noreply.github.com>
This commit is contained in:
parent
417b1d7a66
commit
138f7de18f
@ -3,7 +3,6 @@
|
||||
|
||||
require "cli/parser"
|
||||
require "livecheck/livecheck"
|
||||
require "livecheck/skip_conditions"
|
||||
|
||||
module Homebrew
|
||||
extend T::Sig
|
||||
@ -28,7 +27,6 @@ module Homebrew
|
||||
args = bump_args.parse
|
||||
|
||||
requested_formulae = args.named.to_formulae.presence
|
||||
|
||||
requested_limit = args.limit.to_i if args.limit.present?
|
||||
|
||||
if requested_formulae
|
||||
@ -96,7 +94,7 @@ module Homebrew
|
||||
)
|
||||
latest = version_info[:latest] if version_info.present?
|
||||
|
||||
return "not found" if latest.blank?
|
||||
return "unable to get versions" if latest.blank?
|
||||
|
||||
latest.to_s
|
||||
end
|
||||
@ -118,7 +116,8 @@ module Homebrew
|
||||
end
|
||||
|
||||
def display(formula, current_version, repology_latest, livecheck_latest, pull_requests)
|
||||
title = if up_to_date?(current_version, repology_latest, livecheck_latest)
|
||||
title = if current_version == repology_latest &&
|
||||
current_version == livecheck_latest
|
||||
"#{formula} is up to date!"
|
||||
else
|
||||
formula.name
|
||||
|
||||
@ -60,12 +60,9 @@ module Homebrew
|
||||
@livecheck_strategy_names.freeze
|
||||
end
|
||||
|
||||
# Identify taps other than homebrew/core and homebrew/cask in use
|
||||
# for current formulae and casks and load additional Strategy
|
||||
# files them.
|
||||
sig do
|
||||
params(formulae_and_casks_to_check: T::Enumerable[T.any(Formula, Cask::Cask)]).void
|
||||
end
|
||||
# Uses `formulae_and_casks_to_check` to identify taps in use other than
|
||||
# homebrew/core and homebrew/cask and loads strategies from them.
|
||||
sig { params(formulae_and_casks_to_check: T::Enumerable[T.any(Formula, Cask::Cask)]).void }
|
||||
def load_other_tap_strategies(formulae_and_casks_to_check)
|
||||
other_taps = {}
|
||||
formulae_and_casks_to_check.each do |formula_or_cask|
|
||||
|
||||
@ -21,10 +21,8 @@ module Repology
|
||||
end
|
||||
|
||||
def single_package_query(name)
|
||||
url = %W[
|
||||
https://repology.org/tools/project-by?repo=homebrew&
|
||||
name_type=srcname&target_page=api_v1_project&name=#{name}
|
||||
].join
|
||||
url = "https://repology.org/tools/project-by?repo=homebrew&" \
|
||||
"name_type=srcname&target_page=api_v1_project&name=#{name}"
|
||||
|
||||
output, _errors, _status = curl_output("--location", url.to_s)
|
||||
|
||||
@ -62,8 +60,8 @@ module Repology
|
||||
end
|
||||
|
||||
def latest_version(repositories)
|
||||
# The status is "unique" when the package is present only in Homebrew, so Repology
|
||||
# has no way of knowing if the package is up-to-date.
|
||||
# The status is "unique" when the package is present only in Homebrew, so
|
||||
# Repology has no way of knowing if the package is up-to-date.
|
||||
is_unique = repositories.find do |repo|
|
||||
repo["status"] == "unique"
|
||||
end.present?
|
||||
@ -74,7 +72,8 @@ module Repology
|
||||
repo["status"] == "newest"
|
||||
end
|
||||
|
||||
# Repology cannot identify "newest" versions for packages without a version scheme
|
||||
# Repology cannot identify "newest" versions for packages without a version
|
||||
# scheme
|
||||
return "no latest version" if latest_version.blank?
|
||||
|
||||
latest_version["version"]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user