livecheck: create constant for no versions message

This commit is contained in:
Sam Ford 2025-02-19 15:06:00 -05:00
parent a7cacfff1c
commit 6cfe151292
No known key found for this signature in database
GPG Key ID: 7AF5CBEE1DD6F76D

View File

@ -14,6 +14,7 @@ module Homebrew
# for formulae.
module Livecheck
NO_CURRENT_VERSION_MSG = "Unable to identify current version"
NO_VERSIONS_MSG = "Unable to get versions"
UNSTABLE_VERSION_KEYWORDS = T.let(%w[
alpha
@ -298,7 +299,7 @@ module Homebrew
verbose:,
)
if res_version_info.empty?
status_hash(resource, "error", ["Unable to get versions"], verbose:)
status_hash(resource, "error", [NO_VERSIONS_MSG], verbose:)
else
res_version_info
end
@ -308,13 +309,12 @@ module Homebrew
end
if latest.blank?
no_versions_msg = "Unable to get versions"
raise Livecheck::Error, no_versions_msg unless json
raise Livecheck::Error, NO_VERSIONS_MSG unless json
next if quiet
next version_info if version_info.is_a?(Hash) && version_info[:status] && version_info[:messages]
latest_info = status_hash(formula_or_cask, "error", [no_versions_msg], full_name: use_full_name,
latest_info = status_hash(formula_or_cask, "error", [NO_VERSIONS_MSG], full_name: use_full_name,
verbose:)
if check_for_resources
unless verbose
@ -995,7 +995,7 @@ module Homebrew
res_current = T.must(resource.version)
res_latest = Version.new(match_version_map.values.max_by { |v| LivecheckVersion.create(resource, v) })
return status_hash(resource, "error", ["Unable to get versions"], verbose:) if res_latest.blank?
return status_hash(resource, "error", [NO_VERSIONS_MSG], verbose:) if res_latest.blank?
is_outdated = res_current < res_latest
is_newer_than_upstream = res_current > res_latest