dev-cmd/bump-*-pr: automatically tap core taps if needed.

If the tap isn't tapped already, automatically tap it.
This commit is contained in:
Mike McQuaid 2025-08-18 17:49:06 +01:00
parent 0cadd6d0c1
commit 93807db8c2
No known key found for this signature in database
2 changed files with 31 additions and 8 deletions

View File

@ -71,7 +71,16 @@ module Homebrew
# Use the user's browser, too. # Use the user's browser, too.
ENV["BROWSER"] = EnvConfig.browser ENV["BROWSER"] = EnvConfig.browser
cask = args.named.to_casks.fetch(0) @cask_retried = T.let(false, T.nilable(T::Boolean))
cask = begin
args.named.to_casks.fetch(0)
rescue Cask::CaskUnavailableError
raise if @cask_retried
CoreCaskTap.instance.install(force: true)
@cask_retried = true
retry
end
odie "This cask is not in a tap!" if cask.tap.blank? 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? odie "This cask's tap is not a Git repository!" unless cask.tap.git?

View File

@ -105,14 +105,28 @@ module Homebrew
# Use the user's browser, too. # Use the user's browser, too.
ENV["BROWSER"] = Homebrew::EnvConfig.browser ENV["BROWSER"] = Homebrew::EnvConfig.browser
@tap_retried = T.let(false, T.nilable(T::Boolean))
begin
formula = args.named.to_formulae.first formula = args.named.to_formulae.first
raise FormulaUnspecifiedError if formula.blank? raise FormulaUnspecifiedError if formula.blank?
odie "This formula is disabled!" if formula.disabled? raise ArgumentError, "This formula is disabled!" if formula.disabled?
odie "This formula is deprecated and does not build!" if formula.deprecation_reason == :does_not_build if formula.deprecation_reason == :does_not_build
raise ArgumentError, "This formula is deprecated and does not build!"
end
tap = formula.tap tap = formula.tap
odie "This formula is not in a tap!" if tap.blank? raise ArgumentError, "This formula is not in a tap!" if tap.blank?
odie "This formula's tap is not a Git repository!" unless tap.git? raise ArgumentError, "This formula's tap is not a Git repository!" unless tap.git?
formula
rescue ArgumentError => e
odie e.message if @tap_retried
CoreTap.instance.install(force: true)
@tap_retried = true
retry
end
odie <<~EOS unless tap.allow_bump?(formula.name) odie <<~EOS unless tap.allow_bump?(formula.name)
Whoops, the #{formula.name} formula has its version update Whoops, the #{formula.name} formula has its version update