diff --git a/Library/Homebrew/dev-cmd/bump-cask-pr.rb b/Library/Homebrew/dev-cmd/bump-cask-pr.rb index d2fcd366da..25728e70e4 100644 --- a/Library/Homebrew/dev-cmd/bump-cask-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-cask-pr.rb @@ -89,19 +89,13 @@ module Homebrew odie "This cask is not in a tap!" if cask.tap.blank? odie "This cask's tap is not a Git repository!" unless cask.tap.git? - if ENV.fetch("HOMEBREW_TEST_BOT_AUTOBUMP", false).blank? && - (cask.tap.core_cask_tap? && - (autobump_file_path = cask.tap.path/Tap::HOMEBREW_TAP_AUTOBUMP_FILE) && - autobump_file_path.exist? && - autobump_file_path.readlines(chomp: true).include?(cask.token)) - odie <<~EOS - Whoops, the #{cask.token} cask has its version update - pull requests automatically opened by BrewTestBot! - We'd still love your contributions, though, so try another one - that's not in the autobump list: - #{Formatter.url("#{cask.tap.remote}/blob/master/.github/autobump.txt")} - EOS - end + odie <<~EOS unless cask.tap.allow_bump?(cask.token) + Whoops, the #{cask.token} cask has its version update + pull requests automatically opened by BrewTestBot! + We'd still love your contributions, though, so try another one + that's not in the autobump list: + #{Formatter.url("#{cask.tap.remote}/blob/master/.github/autobump.txt")} + EOS new_version = BumpVersionParser.new( general: args.version, diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index 3295615ce2..e85825585b 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -114,19 +114,13 @@ module Homebrew odie "This formula is not in a tap!" if formula.tap.blank? odie "This formula's tap is not a Git repository!" unless formula.tap.git? - if ENV.fetch("HOMEBREW_TEST_BOT_AUTOBUMP", nil).blank? && - (formula.tap.core_tap? && - (autobump_file_path = formula.tap.path/Tap::HOMEBREW_TAP_AUTOBUMP_FILE) && - autobump_file_path.exist? && - autobump_file_path.readlines(chomp: true).include?(formula.name)) - odie <<~EOS - Whoops, the #{formula.name} formula has its version update - pull requests automatically opened by BrewTestBot! - We'd still love your contributions, though, so try another one - that's not in the autobump list: - #{Formatter.url("#{formula.tap.remote}/blob/master/.github/autobump.txt")} - EOS - end + odie <<~EOS unless formula.tap.allow_bump?(formula.name) + Whoops, the #{formula.name} formula has its version update + pull requests automatically opened by BrewTestBot! + We'd still love your contributions, though, so try another one + that's not in the autobump list: + #{Formatter.url("#{formula.tap.remote}/blob/master/.github/autobump.txt")} + EOS formula_spec = formula.stable odie "#{formula}: no stable specification found!" if formula_spec.blank? diff --git a/Library/Homebrew/dev-cmd/bump.rb b/Library/Homebrew/dev-cmd/bump.rb index b31f851f9c..bd552c70f0 100644 --- a/Library/Homebrew/dev-cmd/bump.rb +++ b/Library/Homebrew/dev-cmd/bump.rb @@ -230,16 +230,20 @@ module Homebrew } def skip_ineligible_formulae(formula_or_cask) if formula_or_cask.is_a?(Formula) - return false if !formula_or_cask.disabled? && !formula_or_cask.head_only? - + skip = formula_or_cask.disabled? || formula_or_cask.head_only? name = formula_or_cask.name text = "Formula is #{formula_or_cask.disabled? ? "disabled" : "HEAD-only"}.\n" else - return false unless formula_or_cask.disabled? - + skip = formula_or_cask.disabled? name = formula_or_cask.token text = "Cask is disabled.\n" end + unless formula_or_cask.tap.allow_bump?(name) + skip = true + text = "#{text.split.first} is on autobump list.\n" + end + return false unless skip + ohai name puts text true diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index 91334efa18..5025a76a7b 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -847,6 +847,22 @@ class Tap end end + # Array with autobump names + sig { returns(T::Array[String]) } + def autobump + @autobump ||= if (autobump_file = path/HOMEBREW_TAP_AUTOBUMP_FILE).file? + autobump_file.readlines(chomp: true) + else + [] + end + end + + # Whether this {Tap} allows running bump commands on the given {Formula} or {Cask}. + sig { params(formula_or_cask_name: String).returns(T::Boolean) } + def allow_bump?(formula_or_cask_name) + ENV["HOMEBREW_TEST_BOT_AUTOBUMP"].present? || !official? || autobump.exclude?(formula_or_cask_name) + end + # Hash with audit exceptions sig { returns(Hash) } def audit_exceptions @@ -1161,6 +1177,15 @@ class CoreTap < AbstractCoreTap end end + # @private + sig { returns(T::Array[String]) } + def autobump + @autobump ||= begin + ensure_installed! + super + end + end + # @private sig { returns(Hash) } def audit_exceptions