Don't tap user-untapped official taps

This commit is contained in:
Rylan Polster 2021-01-19 17:55:03 -05:00
parent 152eac333b
commit 3ca68c076e
No known key found for this signature in database
GPG Key ID: 46A744940CFF4D64
3 changed files with 27 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -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.