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