refactor throttled update logic to improve efficiency

This commit is contained in:
Dustin Rodrigues 2020-07-11 11:28:37 -04:00
parent e9c7c26e0a
commit 963605e682
2 changed files with 14 additions and 17 deletions

View File

@ -571,13 +571,13 @@ module Homebrew
imagemagick@6
].freeze
THROTTLED_DENYLIST = {
"aws-sdk-cpp" => "10",
"awscli@1" => "10",
"balena-cli" => "10",
"gatsby-cli" => "10",
"quicktype" => "10",
"vim" => "50",
THROTTLED_FORMULAE = {
"aws-sdk-cpp" => 10,
"awscli@1" => 10,
"balena-cli" => 10,
"gatsby-cli" => 10,
"quicktype" => 10,
"vim" => 50,
}.freeze
UNSTABLE_ALLOWLIST = {
@ -667,15 +667,6 @@ module Homebrew
problem head_spec_message unless VERSIONED_HEAD_SPEC_ALLOWLIST.include?(formula.name)
end
THROTTLED_DENYLIST.each do |f, v|
next if formula.stable.nil?
version = formula.stable.version.to_s.split(".").last.to_i
if f == formula.name && version.modulo(v.to_i).nonzero?
problem "should only be updated every #{v} releases on multiples of #{v}"
end
end
stable = formula.stable
return unless stable
return unless stable.url
@ -686,6 +677,12 @@ module Homebrew
.split(".", 3)
.map(&:to_i)
formula_suffix = stable_version_string.split(".").last.to_i
throttled_rate = THROTTLED_FORMULAE[formula.name]
if throttled_rate && formula_suffix.modulo(throttled_rate).nonzero?
problem "should only be updated every #{throttled_rate} releases on multiples of #{throttled_rate}"
end
case (url = stable.url)
when /[\d._-](alpha|beta|rc\d)/
matched = Regexp.last_match(1)

View File

@ -542,7 +542,7 @@ module Homebrew
include_examples "formulae exist", described_class::VERSIONED_KEG_ONLY_ALLOWLIST
include_examples "formulae exist", described_class::VERSIONED_HEAD_SPEC_ALLOWLIST
include_examples "formulae exist", described_class::USES_FROM_MACOS_ALLOWLIST
include_examples "formulae exist", described_class::THROTTLED_DENYLIST.keys
include_examples "formulae exist", described_class::THROTTLED_FORMULAE.keys
include_examples "formulae exist", described_class::UNSTABLE_ALLOWLIST.keys
include_examples "formulae exist", described_class::GNOME_DEVEL_ALLOWLIST.keys
end