Only use Sparkle strategy if URL is specified explicitly.
This commit is contained in:
parent
9017778326
commit
0fe3bf7c7f
@ -435,9 +435,9 @@ module Homebrew
|
|||||||
|
|
||||||
has_livecheckable = formula_or_cask.livecheckable?
|
has_livecheckable = formula_or_cask.livecheckable?
|
||||||
livecheck = formula_or_cask.livecheck
|
livecheck = formula_or_cask.livecheck
|
||||||
|
livecheck_url = livecheck.url
|
||||||
livecheck_regex = livecheck.regex
|
livecheck_regex = livecheck.regex
|
||||||
livecheck_strategy = livecheck.strategy
|
livecheck_strategy = livecheck.strategy
|
||||||
livecheck_url = livecheck.url
|
|
||||||
|
|
||||||
urls = [livecheck_url] if livecheck_url.present?
|
urls = [livecheck_url] if livecheck_url.present?
|
||||||
urls ||= checkable_urls(formula_or_cask)
|
urls ||= checkable_urls(formula_or_cask)
|
||||||
@ -475,7 +475,9 @@ module Homebrew
|
|||||||
strategies = Strategy.from_url(
|
strategies = Strategy.from_url(
|
||||||
url,
|
url,
|
||||||
livecheck_strategy: livecheck_strategy,
|
livecheck_strategy: livecheck_strategy,
|
||||||
|
url_provided: livecheck_url.present?,
|
||||||
regex_provided: livecheck_regex.present?,
|
regex_provided: livecheck_regex.present?,
|
||||||
|
block_provided: livecheck.strategy_block.present?,
|
||||||
)
|
)
|
||||||
strategy = Strategy.from_symbol(livecheck_strategy)
|
strategy = Strategy.from_symbol(livecheck_strategy)
|
||||||
strategy ||= strategies.first
|
strategy ||= strategies.first
|
||||||
@ -490,8 +492,8 @@ module Homebrew
|
|||||||
puts "Regex: #{livecheck_regex.inspect}" if livecheck_regex.present?
|
puts "Regex: #{livecheck_regex.inspect}" if livecheck_regex.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
if livecheck_strategy == :page_match && livecheck_regex.blank?
|
if livecheck_strategy == :page_match && (livecheck_regex.blank? && livecheck.strategy_block.blank?)
|
||||||
odebug "#{strategy_name} strategy requires a regex"
|
odebug "#{strategy_name} strategy requires a regex or block"
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -57,12 +57,16 @@ module Homebrew
|
|||||||
# @param regex_provided [Boolean] whether a regex is provided in the
|
# @param regex_provided [Boolean] whether a regex is provided in the
|
||||||
# `livecheck` block
|
# `livecheck` block
|
||||||
# @return [Array]
|
# @return [Array]
|
||||||
def from_url(url, livecheck_strategy: nil, regex_provided: nil)
|
def from_url(url, livecheck_strategy: nil, url_provided: nil, regex_provided: nil, block_provided: nil)
|
||||||
usable_strategies = strategies.values.select do |strategy|
|
usable_strategies = strategies.values.select do |strategy|
|
||||||
if strategy == PageMatch
|
if strategy == PageMatch
|
||||||
# Only treat the `PageMatch` strategy as usable if a regex is
|
# Only treat the `PageMatch` strategy as usable if a regex is
|
||||||
# present in the `livecheck` block
|
# present in the `livecheck` block
|
||||||
next unless regex_provided
|
next unless (regex_provided || block_provided)
|
||||||
|
elsif strategy == Sparkle && (livecheck_strategy || !url_provided)
|
||||||
|
# Skip the `Sparkle` strategy if a strategy is specified explicitly
|
||||||
|
# or if the URL is not specified explicitly.
|
||||||
|
next
|
||||||
elsif strategy.const_defined?(:PRIORITY) &&
|
elsif strategy.const_defined?(:PRIORITY) &&
|
||||||
!strategy::PRIORITY.positive? &&
|
!strategy::PRIORITY.positive? &&
|
||||||
from_symbol(livecheck_strategy) != strategy
|
from_symbol(livecheck_strategy) != strategy
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user