Merge pull request #19338 from Homebrew/livecheck/refactor-head-only-formula
livecheck: refactor HEAD-only formula handling
This commit is contained in:
commit
7e182d04d7
@ -287,6 +287,7 @@ module Cask
|
|||||||
#
|
#
|
||||||
# @see DSL::Version
|
# @see DSL::Version
|
||||||
# @api public
|
# @api public
|
||||||
|
sig { params(arg: T.nilable(T.any(String, Symbol))).returns(T.nilable(DSL::Version)) }
|
||||||
def version(arg = nil)
|
def version(arg = nil)
|
||||||
set_unique_stanza(:version, arg.nil?) do
|
set_unique_stanza(:version, arg.nil?) do
|
||||||
if !arg.is_a?(String) && arg != :latest
|
if !arg.is_a?(String) && arg != :latest
|
||||||
|
|||||||
@ -2403,6 +2403,7 @@ class Formula
|
|||||||
|
|
||||||
# Returns the {PkgVersion} for this formula if it is installed.
|
# Returns the {PkgVersion} for this formula if it is installed.
|
||||||
# If not, return `nil`.
|
# If not, return `nil`.
|
||||||
|
sig { returns(T.nilable(PkgVersion)) }
|
||||||
def any_installed_version
|
def any_installed_version
|
||||||
any_installed_keg&.version
|
any_installed_keg&.version
|
||||||
end
|
end
|
||||||
|
|||||||
@ -388,6 +388,7 @@ class Keg
|
|||||||
(path/"share/emacs/site-lisp"/name).children.any? { |f| ELISP_EXTENSIONS.include? f.extname }
|
(path/"share/emacs/site-lisp"/name).children.any? { |f| ELISP_EXTENSIONS.include? f.extname }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { returns(PkgVersion) }
|
||||||
def version
|
def version
|
||||||
require "pkg_version"
|
require "pkg_version"
|
||||||
PkgVersion.parse(path.basename.to_s)
|
PkgVersion.parse(path.basename.to_s)
|
||||||
|
|||||||
@ -13,6 +13,9 @@ module Homebrew
|
|||||||
# command. These methods print the requested livecheck information
|
# command. These methods print the requested livecheck information
|
||||||
# for formulae.
|
# for formulae.
|
||||||
module Livecheck
|
module Livecheck
|
||||||
|
NO_CURRENT_VERSION_MSG = "Unable to identify current version"
|
||||||
|
NO_VERSIONS_MSG = "Unable to get versions"
|
||||||
|
|
||||||
UNSTABLE_VERSION_KEYWORDS = T.let(%w[
|
UNSTABLE_VERSION_KEYWORDS = T.let(%w[
|
||||||
alpha
|
alpha
|
||||||
beta
|
beta
|
||||||
@ -249,13 +252,20 @@ module Homebrew
|
|||||||
# comparison.
|
# comparison.
|
||||||
current = if formula
|
current = if formula
|
||||||
if formula.head_only?
|
if formula.head_only?
|
||||||
Version.new(formula.any_installed_version.version.commit)
|
formula_commit = formula.any_installed_version&.version&.commit
|
||||||
else
|
Version.new(formula_commit) if formula_commit
|
||||||
T.must(formula.stable).version
|
elsif (stable = formula.stable)
|
||||||
|
stable.version
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Version.new(formula_or_cask.version)
|
Version.new(formula_or_cask.version)
|
||||||
end
|
end
|
||||||
|
unless current
|
||||||
|
raise Livecheck::Error, NO_CURRENT_VERSION_MSG unless json
|
||||||
|
next if quiet
|
||||||
|
|
||||||
|
next status_hash(formula_or_cask, "error", [NO_CURRENT_VERSION_MSG], full_name: use_full_name, verbose:)
|
||||||
|
end
|
||||||
|
|
||||||
current_str = current.to_s
|
current_str = current.to_s
|
||||||
current = LivecheckVersion.create(formula_or_cask, current)
|
current = LivecheckVersion.create(formula_or_cask, current)
|
||||||
@ -289,7 +299,7 @@ module Homebrew
|
|||||||
verbose:,
|
verbose:,
|
||||||
)
|
)
|
||||||
if res_version_info.empty?
|
if res_version_info.empty?
|
||||||
status_hash(resource, "error", ["Unable to get versions"], verbose:)
|
status_hash(resource, "error", [NO_VERSIONS_MSG], verbose:)
|
||||||
else
|
else
|
||||||
res_version_info
|
res_version_info
|
||||||
end
|
end
|
||||||
@ -299,13 +309,12 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
if latest.blank?
|
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 if quiet
|
||||||
|
|
||||||
next version_info if version_info.is_a?(Hash) && version_info[:status] && version_info[:messages]
|
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:)
|
verbose:)
|
||||||
if check_for_resources
|
if check_for_resources
|
||||||
unless verbose
|
unless verbose
|
||||||
@ -986,7 +995,7 @@ module Homebrew
|
|||||||
res_current = T.must(resource.version)
|
res_current = T.must(resource.version)
|
||||||
res_latest = Version.new(match_version_map.values.max_by { |v| LivecheckVersion.create(resource, v) })
|
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_outdated = res_current < res_latest
|
||||||
is_newer_than_upstream = res_current > res_latest
|
is_newer_than_upstream = res_current > res_latest
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user