diff --git a/Library/Homebrew/dev-cmd/bump-cask-pr.rb b/Library/Homebrew/dev-cmd/bump-cask-pr.rb index bf9d9aafe5..b132275ed9 100644 --- a/Library/Homebrew/dev-cmd/bump-cask-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-cask-pr.rb @@ -71,7 +71,16 @@ module Homebrew # Use the user's browser, too. 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's tap is not a Git repository!" unless cask.tap.git? diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index f6d9d83b5e..98af7df840 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -105,14 +105,28 @@ module Homebrew # Use the user's browser, too. ENV["BROWSER"] = Homebrew::EnvConfig.browser - formula = args.named.to_formulae.first - raise FormulaUnspecifiedError if formula.blank? + @tap_retried = T.let(false, T.nilable(T::Boolean)) + begin + formula = args.named.to_formulae.first + raise FormulaUnspecifiedError if formula.blank? - odie "This formula is disabled!" if formula.disabled? - odie "This formula is deprecated and does not build!" if formula.deprecation_reason == :does_not_build - tap = formula.tap - odie "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 is disabled!" if formula.disabled? + if formula.deprecation_reason == :does_not_build + raise ArgumentError, "This formula is deprecated and does not build!" + end + + tap = formula.tap + raise ArgumentError, "This formula is not in a tap!" if tap.blank? + 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) Whoops, the #{formula.name} formula has its version update