Only require livecheck block URL when appropriate

`ExtractPlist` doesn't require a URL like other strategies (it takes
a `Cask` instead) but we've had to provide one in existing
`livecheck` blocks to get past this requirement in livecheck. This
commit makes it so this requirement is only enforced when a
strategy's `#find_versions` method has a required `url` parameter
(not an optional one, as in `ExtractPlist`).
This commit is contained in:
Sam Ford 2022-06-24 00:08:25 -04:00
parent d7a26cd6d3
commit 2194f6e12b
No known key found for this signature in database
GPG Key ID: 7AF5CBEE1DD6F76D

View File

@ -563,6 +563,7 @@ module Homebrew
# Identifies the latest version of the formula and returns a Hash containing
# the version information. Returns nil if a latest version couldn't be found.
# rubocop:disable Metrics/CyclomaticComplexity
sig {
params(
formula_or_cask: T.any(Formula, Cask::Cask),
@ -657,7 +658,7 @@ module Homebrew
end
if livecheck_strategy.present?
if livecheck_url.blank?
if livecheck_url.blank? && strategy.method(:find_versions).parameters.include?([:keyreq, :url])
odebug "#{strategy_name} strategy requires a URL"
next
elsif livecheck_strategy != :page_match && strategies.exclude?(strategy)
@ -768,6 +769,7 @@ module Homebrew
nil
end
# rubocop:enable Metrics/CyclomaticComplexity
end
# rubocop:enable Metrics/ModuleLength
end