livecheck: allow parent formula reference in resources
This commit is contained in:
parent
f5143810f9
commit
e2df3fee81
@ -60,14 +60,14 @@ class Livecheck
|
|||||||
sig {
|
sig {
|
||||||
params(
|
params(
|
||||||
# Name of formula to inherit livecheck info from.
|
# Name of formula to inherit livecheck info from.
|
||||||
formula_name: String,
|
formula_name: T.any(String, Symbol),
|
||||||
).returns(T.nilable(String))
|
).returns(T.nilable(T.any(String, Symbol)))
|
||||||
}
|
}
|
||||||
def formula(formula_name = T.unsafe(nil))
|
def formula(formula_name = T.unsafe(nil))
|
||||||
case formula_name
|
case formula_name
|
||||||
when nil
|
when nil
|
||||||
@referenced_formula_name
|
@referenced_formula_name
|
||||||
when String
|
when String, :parent
|
||||||
@referenced_formula_name = formula_name
|
@referenced_formula_name = formula_name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -850,6 +850,7 @@ module Homebrew
|
|||||||
resource_version_info = {}
|
resource_version_info = {}
|
||||||
|
|
||||||
livecheck = resource.livecheck
|
livecheck = resource.livecheck
|
||||||
|
livecheck_reference = livecheck.formula
|
||||||
livecheck_url = livecheck.url
|
livecheck_url = livecheck.url
|
||||||
livecheck_regex = livecheck.regex
|
livecheck_regex = livecheck.regex
|
||||||
livecheck_strategy = livecheck.strategy
|
livecheck_strategy = livecheck.strategy
|
||||||
@ -858,6 +859,7 @@ module Homebrew
|
|||||||
livecheck_url_string = livecheck_url_to_string(livecheck_url, resource) if livecheck_url
|
livecheck_url_string = livecheck_url_to_string(livecheck_url, resource) if livecheck_url
|
||||||
|
|
||||||
urls = [livecheck_url_string] if livecheck_url_string
|
urls = [livecheck_url_string] if livecheck_url_string
|
||||||
|
urls = ["None"] if livecheck_reference == :parent
|
||||||
urls ||= checkable_urls(resource)
|
urls ||= checkable_urls(resource)
|
||||||
|
|
||||||
checked_urls = []
|
checked_urls = []
|
||||||
@ -893,6 +895,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
puts "Strategy: #{strategy.blank? ? "None" : strategy_name}"
|
puts "Strategy: #{strategy.blank? ? "None" : strategy_name}"
|
||||||
puts "Regex: #{livecheck_regex.inspect}" if livecheck_regex.present?
|
puts "Regex: #{livecheck_regex.inspect}" if livecheck_regex.present?
|
||||||
|
puts "Formula Ref: #{resource.owner.name} (parent)" if livecheck_reference == :parent
|
||||||
end
|
end
|
||||||
|
|
||||||
if livecheck_strategy.present?
|
if livecheck_strategy.present?
|
||||||
@ -904,19 +907,26 @@ module Homebrew
|
|||||||
next
|
next
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
puts if debug && strategy.blank?
|
puts if debug && strategy.blank? && livecheck_reference != :parent
|
||||||
next if strategy.blank?
|
next if strategy.blank? && livecheck_reference != :parent
|
||||||
|
|
||||||
strategy_args = {
|
if livecheck_reference == :parent
|
||||||
url:,
|
match_version_map = { formula_latest => Version.new(formula_latest) }
|
||||||
regex: livecheck_regex,
|
cached = true
|
||||||
homebrew_curl: false,
|
else
|
||||||
}.compact
|
strategy_args = {
|
||||||
|
url:,
|
||||||
|
regex: livecheck_regex,
|
||||||
|
homebrew_curl: false,
|
||||||
|
}.compact
|
||||||
|
|
||||||
|
strategy_data = strategy.find_versions(**strategy_args, &livecheck_strategy_block)
|
||||||
|
match_version_map = strategy_data[:matches]
|
||||||
|
regex = strategy_data[:regex]
|
||||||
|
messages = strategy_data[:messages]
|
||||||
|
cached = strategy_data[:cached]
|
||||||
|
end
|
||||||
|
|
||||||
strategy_data = strategy.find_versions(**strategy_args, &livecheck_strategy_block)
|
|
||||||
match_version_map = strategy_data[:matches]
|
|
||||||
regex = strategy_data[:regex]
|
|
||||||
messages = strategy_data[:messages]
|
|
||||||
checked_urls << url
|
checked_urls << url
|
||||||
|
|
||||||
if messages.is_a?(Array) && match_version_map.blank?
|
if messages.is_a?(Array) && match_version_map.blank?
|
||||||
@ -927,14 +937,14 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
if debug
|
if debug
|
||||||
if strategy_data[:url].present? && strategy_data[:url] != url
|
if strategy_data&.dig(:url).present? && strategy_data[:url] != url
|
||||||
puts "URL (strategy): #{strategy_data[:url]}"
|
puts "URL (strategy): #{strategy_data[:url]}"
|
||||||
end
|
end
|
||||||
puts "URL (final): #{strategy_data[:final_url]}" if strategy_data[:final_url].present?
|
puts "URL (final): #{strategy_data[:final_url]}" if strategy_data&.dig(:final_url).present?
|
||||||
if strategy_data[:regex].present? && strategy_data[:regex] != livecheck_regex
|
if strategy_data&.dig(:regex).present? && strategy_data[:regex] != livecheck_regex
|
||||||
puts "Regex (strategy): #{strategy_data[:regex].inspect}"
|
puts "Regex (strategy): #{strategy_data[:regex].inspect}"
|
||||||
end
|
end
|
||||||
puts "Cached?: Yes" if strategy_data[:cached] == true
|
puts "Cached?: Yes" if cached == true
|
||||||
end
|
end
|
||||||
|
|
||||||
match_version_map.delete_if do |_match, version|
|
match_version_map.delete_if do |_match, version|
|
||||||
@ -987,16 +997,16 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
resource_version_info[:meta][:url][:original] = original_url
|
resource_version_info[:meta][:url][:original] = original_url
|
||||||
resource_version_info[:meta][:url][:processed] = url if url != original_url
|
resource_version_info[:meta][:url][:processed] = url if url != original_url
|
||||||
if strategy_data[:url].present? && strategy_data[:url] != url
|
if strategy_data&.dig(:url).present? && strategy_data[:url] != url
|
||||||
resource_version_info[:meta][:url][:strategy] = strategy_data[:url]
|
resource_version_info[:meta][:url][:strategy] = strategy_data[:url]
|
||||||
end
|
end
|
||||||
resource_version_info[:meta][:url][:final] = strategy_data[:final_url] if strategy_data[:final_url]
|
resource_version_info[:meta][:url][:final] = strategy_data[:final_url] if strategy_data&.dig(:final_url)
|
||||||
resource_version_info[:meta][:strategy] = strategy.present? ? strategy_name : nil
|
resource_version_info[:meta][:strategy] = strategy.present? ? strategy_name : nil
|
||||||
if strategies.present?
|
if strategies.present?
|
||||||
resource_version_info[:meta][:strategies] = strategies.map { |s| livecheck_strategy_names[s] }
|
resource_version_info[:meta][:strategies] = strategies.map { |s| livecheck_strategy_names[s] }
|
||||||
end
|
end
|
||||||
resource_version_info[:meta][:regex] = regex.inspect if regex.present?
|
resource_version_info[:meta][:regex] = regex.inspect if regex.present?
|
||||||
resource_version_info[:meta][:cached] = true if strategy_data[:cached] == true
|
resource_version_info[:meta][:cached] = true if cached == true
|
||||||
rescue => e
|
rescue => e
|
||||||
Homebrew.failed = true
|
Homebrew.failed = true
|
||||||
if json
|
if json
|
||||||
|
Loading…
x
Reference in New Issue
Block a user