Skip to content
Snippets Groups Projects
Unverified Commit 5f9140f8 authored by Dawid Dziurla's avatar Dawid Dziurla
Browse files

untap: add --force switch


Co-authored-by: default avatarEric Knibbe <enk3@outlook.com>
parent fc0ab4c0
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# frozen_string_literal: true # frozen_string_literal: true
require "cli/parser" require "cli/parser"
require "formula"
module Homebrew module Homebrew
extend T::Sig extend T::Sig
...@@ -16,6 +17,8 @@ module Homebrew ...@@ -16,6 +17,8 @@ module Homebrew
Remove a tapped formula repository. Remove a tapped formula repository.
EOS EOS
switch "-f", "--force",
description: "Untap even if formulae or casks from this tap are currently installed."
min_named 1 min_named 1
end end
...@@ -28,6 +31,20 @@ module Homebrew ...@@ -28,6 +31,20 @@ module Homebrew
tap = Tap.fetch(tapname) tap = Tap.fetch(tapname)
odie "Untapping #{tap} is not allowed" if tap.core_tap? 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.length.positive? || installed_tap_casks.length.positive?
if args.force?
opoo "Untapping #{tap} even though it contains formulae or casks that are currently installed."
else
odie <<~EOS
Refusing to untap #{tap} because it contains the following installed formulae or casks:
#{(installed_tap_formulae + installed_tap_casks.map(&:token)).join("\n")}
EOS
end
end
tap.uninstall tap.uninstall
end end
end end
......
...@@ -572,6 +572,9 @@ See also `pin`. ...@@ -572,6 +572,9 @@ See also `pin`.
Remove a tapped formula repository. Remove a tapped formula repository.
* `-f`, `--force`:
Untap even if formulae or casks from this tap are currently installed.
### `update` [*`options`*] ### `update` [*`options`*]
Fetch the newest version of Homebrew and all formulae from GitHub using `git`(1) and perform any necessary migrations. Fetch the newest version of Homebrew and all formulae from GitHub using `git`(1) and perform any necessary migrations.
......
...@@ -770,6 +770,10 @@ Unpin \fIformula\fR, allowing them to be upgraded by \fBbrew upgrade\fR \fIformu ...@@ -770,6 +770,10 @@ Unpin \fIformula\fR, allowing them to be upgraded by \fBbrew upgrade\fR \fIformu
.SS "\fBuntap\fR \fItap\fR" .SS "\fBuntap\fR \fItap\fR"
Remove a tapped formula repository\. Remove a tapped formula repository\.
. .
.TP
\fB\-f\fR, \fB\-\-force\fR
Untap even if formulae or casks from this tap are currently installed\.
.
.SS "\fBupdate\fR [\fIoptions\fR]" .SS "\fBupdate\fR [\fIoptions\fR]"
Fetch the newest version of Homebrew and all formulae from GitHub using \fBgit\fR(1) and perform any necessary migrations\. Fetch the newest version of Homebrew and all formulae from GitHub using \fBgit\fR(1) and perform any necessary migrations\.
. .
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment