未验证 提交 f8ded0a4 编辑于 作者: Sam Ford's avatar Sam Ford
浏览文件

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.
上级 085827f6
......@@ -626,13 +626,10 @@ module Homebrew
end
if livecheck_strategy.present?
if livecheck_strategy == :page_match && (livecheck_regex.blank? && livecheck_strategy_block.blank?)
odebug "#{strategy_name} strategy requires a regex or block"
next
elsif livecheck_url.blank?
if livecheck_url.blank?
odebug "#{strategy_name} strategy requires a URL"
next
elsif strategies.exclude?(strategy)
elsif livecheck_strategy != :page_match && strategies.exclude?(strategy)
odebug "#{strategy_name} strategy does not apply to this URL"
next
end
......
......@@ -90,6 +90,10 @@ module Homebrew
).returns(T::Hash[Symbol, T.untyped])
}
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 }
return match_data if url.blank? || (regex.blank? && block.blank?)
......
支持 Markdown
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册