dev-cmd/bump: skip autobump formulae & casks

Instead output a message that corresponding formula/cask is on the
autobump list. This avoids deferring the information to the error
message within `bump-{formula,cask}-pr`.

Signed-off-by: Michael Cho <michael@michaelcho.dev>
This commit is contained in:
Michael Cho 2024-03-05 22:24:43 -05:00
parent 45cd50ba6a
commit 12d1e56ff5
No known key found for this signature in database
GPG Key ID: 55E85E28A7CD1E85
4 changed files with 47 additions and 30 deletions

View File

@ -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
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
end
new_version = BumpVersionParser.new(
general: args.version,

View File

@ -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
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
end
formula_spec = formula.stable
odie "#{formula}: no stable specification found!" if formula_spec.blank?

View File

@ -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

View File

@ -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