Merge pull request #12346 from Rylan12/fix-untap-with-install-from-api

Fix `brew untap` with `HOMEBREW_INSTALL_FROM_API`
This commit is contained in:
Rylan Polster 2021-10-29 13:27:34 -04:00 committed by GitHub
commit dae9a34a85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,21 +27,23 @@ module Homebrew
args.named.to_installed_taps.each do |tap| args.named.to_installed_taps.each do |tap|
odie "Untapping #{tap} is not allowed" if tap.core_tap? && !Homebrew::EnvConfig.install_from_api? odie "Untapping #{tap} is not allowed" if tap.core_tap? && !Homebrew::EnvConfig.install_from_api?
installed_tap_formulae = Formula.installed.select { |formula| formula.tap == tap } if !Homebrew::EnvConfig.install_from_api? || (!tap.core_tap? && tap != "homebrew/cask")
installed_tap_casks = Cask::Caskroom.casks.select { |cask| cask.tap == tap } installed_tap_formulae = Formula.installed.select { |formula| formula.tap == tap }
installed_tap_casks = Cask::Caskroom.casks.select { |cask| cask.tap == tap }
if installed_tap_formulae.present? || installed_tap_casks.present? if installed_tap_formulae.present? || installed_tap_casks.present?
installed_names = (installed_tap_formulae + installed_tap_casks.map(&:token)).join("\n") installed_names = (installed_tap_formulae + installed_tap_casks.map(&:token)).join("\n")
if args.force? || Homebrew::EnvConfig.developer? if args.force? || Homebrew::EnvConfig.developer?
opoo <<~EOS opoo <<~EOS
Untapping #{tap} even though it contains the following installed formulae or casks: Untapping #{tap} even though it contains the following installed formulae or casks:
#{installed_names} #{installed_names}
EOS EOS
else else
odie <<~EOS odie <<~EOS
Refusing to untap #{tap} because it contains the following installed formulae or casks: Refusing to untap #{tap} because it contains the following installed formulae or casks:
#{installed_names} #{installed_names}
EOS EOS
end
end end
end end