PageMatch: Enforce requirements in #find_versions
This aligns `PageMatch` with how cask strategies handle requirements in their `#find_versions` methods. This moves related logic from `Livecheck#latest_version` into the `PageMatch` strategy, which feels a bit more appropriate.
This commit is contained in:
parent
085827f605
commit
f8ded0a435
@ -626,13 +626,10 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
if livecheck_strategy.present?
|
if livecheck_strategy.present?
|
||||||
if livecheck_strategy == :page_match && (livecheck_regex.blank? && livecheck_strategy_block.blank?)
|
if livecheck_url.blank?
|
||||||
odebug "#{strategy_name} strategy requires a regex or block"
|
|
||||||
next
|
|
||||||
elsif livecheck_url.blank?
|
|
||||||
odebug "#{strategy_name} strategy requires a URL"
|
odebug "#{strategy_name} strategy requires a URL"
|
||||||
next
|
next
|
||||||
elsif strategies.exclude?(strategy)
|
elsif livecheck_strategy != :page_match && strategies.exclude?(strategy)
|
||||||
odebug "#{strategy_name} strategy does not apply to this URL"
|
odebug "#{strategy_name} strategy does not apply to this URL"
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|||||||
@ -90,6 +90,10 @@ module Homebrew
|
|||||||
).returns(T::Hash[Symbol, T.untyped])
|
).returns(T::Hash[Symbol, T.untyped])
|
||||||
}
|
}
|
||||||
def self.find_versions(url:, regex: nil, provided_content: nil, **_unused, &block)
|
def self.find_versions(url:, regex: nil, provided_content: nil, **_unused, &block)
|
||||||
|
if regex.blank? && block.blank?
|
||||||
|
raise ArgumentError, "#{T.must(name).demodulize} requires a regex or `strategy` block"
|
||||||
|
end
|
||||||
|
|
||||||
match_data = { matches: {}, regex: regex, url: url }
|
match_data = { matches: {}, regex: regex, url: url }
|
||||||
return match_data if url.blank? || (regex.blank? && block.blank?)
|
return match_data if url.blank? || (regex.blank? && block.blank?)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user