livecheck: Add throttle info to debug, JSON output

This commit is contained in:
Sam Ford 2024-03-20 22:50:14 -04:00 committed by Michael Cho
parent bfec6eecac
commit 25d07c3838
No known key found for this signature in database
GPG Key ID: 55E85E28A7CD1E85

View File

@ -372,9 +372,10 @@ module Homebrew
info[:version] = {
current: current_str,
latest: latest_str,
latest_throttled: version_info&.dig(:latest_throttled),
outdated: is_outdated,
newer_than_upstream: is_newer_than_upstream,
}
}.compact
info[:meta] = {
livecheckable: formula_or_cask.livecheckable?,
}
@ -678,6 +679,7 @@ module Homebrew
livecheck_regex = livecheck.regex || referenced_livecheck&.regex
livecheck_strategy = livecheck.strategy || referenced_livecheck&.strategy
livecheck_strategy_block = livecheck.strategy_block || referenced_livecheck&.strategy_block
livecheck_throttle = livecheck.throttle || referenced_livecheck&.throttle
livecheck_url_string = livecheck_url_to_string(
livecheck_url,
@ -695,6 +697,7 @@ module Homebrew
puts "Cask: #{cask_name(formula_or_cask, full_name:)}"
end
puts "Livecheckable?: #{has_livecheckable ? "Yes" : "No"}"
puts "Throttle: #{livecheck_throttle}" if livecheck_throttle
livecheck_references.each do |ref_formula_or_cask|
case ref_formula_or_cask
@ -826,8 +829,8 @@ module Homebrew
latest: Version.new(match_version_map.values.max_by { |v| LivecheckVersion.create(formula_or_cask, v) }),
}
if (throttle = livecheck.throttle || referenced_livecheck&.throttle)
match_version_map.keep_if { |_match, version| version.patch.to_i.modulo(throttle).zero? }
if livecheck_throttle
match_version_map.keep_if { |_match, version| version.patch.to_i.modulo(livecheck_throttle).zero? }
version_info[:latest_throttled] = if match_version_map.blank?
nil
else
@ -876,6 +879,7 @@ module Homebrew
version_info[:meta][:strategies] = strategies.map { |s| livecheck_strategy_names[s] } if strategies.present?
version_info[:meta][:regex] = regex.inspect if regex.present?
version_info[:meta][:cached] = true if strategy_data[:cached] == true
version_info[:meta][:throttle] = livecheck_throttle if livecheck_throttle
end
return version_info