untap: add --force switch

Co-authored-by: Eric Knibbe <enk3@outlook.com>
This commit is contained in:
Dawid Dziurla 2020-12-04 21:19:48 +01:00
parent 2c77a540b5
commit 6248ab7725
No known key found for this signature in database
GPG Key ID: 7B6D8368172E9B0B

View File

@ -28,6 +28,24 @@ module Homebrew
tap = Tap.fetch(tapname)
odie "Untapping #{tap} is not allowed" if tap.core_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?
installed_names = (installed_tap_formulae + installed_tap_casks.map(&:token)).join("\n")
if args.force? || Homebrew::EnvConfig.developer?
opoo <<~EOS
Untapping #{tap} even though it contains the following installed formulae or casks:
#{installed_names}
EOS
else
odie <<~EOS
Refusing to untap #{tap} because it contains the following installed formulae or casks:
#{installed_names}
EOS
end
end
tap.uninstall
end
end