mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Use Sparkle sorting/filtering in #livecheck_min_os
The `#livecheck_min_os` cask audit method manually replicates some of the `Sparkle` strategy's behavior but in an incomplete way that has lead to inappropriate audit failures at times. This reimplements it to use `Livecheck` methods, so it will align with the `Sparkle` strategy's behavior.
This commit is contained in:
parent
d376b46a7d
commit
28451bd2bc
@ -603,31 +603,25 @@ module Cask
|
|||||||
return if cask.livecheck.strategy_block.present? &&
|
return if cask.livecheck.strategy_block.present? &&
|
||||||
cask.livecheck.strategy_block.parameters[0] == [:opt, :items]
|
cask.livecheck.strategy_block.parameters[0] == [:opt, :items]
|
||||||
|
|
||||||
out, _, status = curl_output("--fail", "--silent", "--location", cask.livecheck.url)
|
content = Homebrew::Livecheck::Strategy.page_content(cask.livecheck.url)[:content]
|
||||||
return unless status.success?
|
return if content.blank?
|
||||||
|
|
||||||
require "rexml/document"
|
|
||||||
|
|
||||||
xml = begin
|
|
||||||
REXML::Document.new(out)
|
|
||||||
rescue REXML::ParseException
|
|
||||||
nil
|
|
||||||
end
|
|
||||||
|
|
||||||
return if xml.blank?
|
|
||||||
|
|
||||||
item = xml.elements["//rss//channel//item"]
|
|
||||||
return if item.blank?
|
|
||||||
|
|
||||||
min_os = item.elements["sparkle:minimumSystemVersion"]&.text
|
|
||||||
min_os = "11" if min_os == "10.16"
|
|
||||||
return if min_os.blank?
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
MacOSVersion.new(min_os).strip_patch
|
items = Homebrew::Livecheck::Strategy::Sparkle.sort_items(
|
||||||
rescue MacOSVersion::Error
|
Homebrew::Livecheck::Strategy::Sparkle.filter_items(
|
||||||
nil
|
Homebrew::Livecheck::Strategy::Sparkle.items_from_content(content),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
rescue
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
return if items.blank?
|
||||||
|
|
||||||
|
min_os = items[0]&.minimum_system_version&.strip_patch
|
||||||
|
# Big Sur is sometimes identified as 10.16, so we override it to the
|
||||||
|
# expected macOS version (11).
|
||||||
|
min_os = MacOSVersion.new("11") if min_os == "10.16"
|
||||||
|
min_os
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { returns(T.nilable(MacOSVersion)) }
|
sig { returns(T.nilable(MacOSVersion)) }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user