diff --git a/Library/Homebrew/brew.rb b/Library/Homebrew/brew.rb index a6299cdc44..be7af80553 100644 --- a/Library/Homebrew/brew.rb +++ b/Library/Homebrew/brew.rb @@ -132,7 +132,10 @@ begin possible_tap = OFFICIAL_CMD_TAPS.find { |_, cmds| cmds.include?(cmd) } possible_tap = Tap.fetch(possible_tap.first) if possible_tap - odie "Unknown command: #{cmd}" if !possible_tap || possible_tap.installed? + untapped_official_taps = Homebrew::Settings.read(:untapped)&.split(";") || [] + if !possible_tap || possible_tap.installed? || untapped_official_taps.include?(possible_tap.name) + odie "Unknown command: #{cmd}" + end # Unset HOMEBREW_HELP to avoid confusing the tap with_env HOMEBREW_HELP: nil do diff --git a/Library/Homebrew/extend/os/mac/tap.rb b/Library/Homebrew/extend/os/mac/tap.rb index 495901ea68..e64fc7cfc9 100644 --- a/Library/Homebrew/extend/os/mac/tap.rb +++ b/Library/Homebrew/extend/os/mac/tap.rb @@ -5,6 +5,9 @@ class Tap def self.install_default_cask_tap_if_necessary return false if default_cask_tap.installed? + untapped_official_taps = Homebrew::Settings.read(:untapped)&.split(";") || [] + return false if untapped_official_taps.include?(default_cask_tap.name) + default_cask_tap.install true end diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index 2e75f812fa..3580d5e41f 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -326,6 +326,17 @@ class Tap .update_from_formula_names!(formula_names) end + if official? + untapped = Homebrew::Settings.read(:untapped)&.split(";") || [] + untapped -= [name] + + if untapped.empty? + Homebrew::Settings.delete :untapped + else + Homebrew::Settings.write :untapped, untapped.join(";") + end + end + return if clone_target return unless private? return if quiet @@ -374,6 +385,15 @@ class Tap Commands.rebuild_commands_completion_list clear_cache + + return unless official? + + untapped = Homebrew::Settings.read(:untapped)&.split(";") || [] + + return if untapped.include? name + + untapped << name + Homebrew::Settings.write :untapped, untapped.join(";") end # True if the {#remote} of {Tap} is customized.