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