Merge pull request #10366 from Rylan12/auto-tap-fix
Don't tap user-untapped official taps
This commit is contained in:
commit
acede7315a
@ -132,7 +132,9 @@ 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?
|
||||
if !possible_tap || possible_tap.installed? || Tap.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
|
||||
|
||||
@ -99,8 +99,6 @@ module Homebrew
|
||||
begin
|
||||
return Cask::CaskLoader.load(name, config: Cask::Config.from_args(@parent))
|
||||
rescue Cask::CaskUnavailableError => e
|
||||
retry if Tap.install_default_cask_tap_if_necessary
|
||||
|
||||
raise e if only == :cask
|
||||
end
|
||||
end
|
||||
|
||||
@ -153,8 +153,14 @@ module Homebrew
|
||||
EOS
|
||||
end
|
||||
|
||||
formulae, casks = args.named.to_formulae_and_casks
|
||||
.partition { |formula_or_cask| formula_or_cask.is_a?(Formula) }
|
||||
begin
|
||||
formulae, casks = args.named.to_formulae_and_casks
|
||||
.partition { |formula_or_cask| formula_or_cask.is_a?(Formula) }
|
||||
rescue FormulaOrCaskUnavailableError, Cask::CaskUnavailableError => e
|
||||
retry if Tap.install_default_cask_tap_if_necessary(force: args.cask?)
|
||||
|
||||
raise e
|
||||
end
|
||||
|
||||
if casks.any?
|
||||
Cask::Cmd::Install.install_casks(
|
||||
|
||||
@ -43,7 +43,7 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
|
||||
tap.uninstall
|
||||
tap.uninstall manual: true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -2,9 +2,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Tap
|
||||
def self.install_default_cask_tap_if_necessary
|
||||
def self.install_default_cask_tap_if_necessary(force: false)
|
||||
return false if default_cask_tap.installed?
|
||||
|
||||
return false if !force && Tap.untapped_official_taps.include?(default_cask_tap.name)
|
||||
|
||||
default_cask_tap.install
|
||||
true
|
||||
end
|
||||
|
||||
@ -67,8 +67,8 @@ class Tap
|
||||
@default_cask_tap ||= fetch("Homebrew", "cask")
|
||||
end
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def self.install_default_cask_tap_if_necessary
|
||||
sig { params(force: T::Boolean).returns(T::Boolean) }
|
||||
def self.install_default_cask_tap_if_necessary(force: false)
|
||||
false
|
||||
end
|
||||
|
||||
@ -326,6 +326,17 @@ class Tap
|
||||
.update_from_formula_names!(formula_names)
|
||||
end
|
||||
|
||||
if official?
|
||||
untapped = self.class.untapped_official_taps
|
||||
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
|
||||
@ -352,7 +363,7 @@ class Tap
|
||||
end
|
||||
|
||||
# Uninstall this {Tap}.
|
||||
def uninstall
|
||||
def uninstall(manual: false)
|
||||
require "descriptions"
|
||||
raise TapUnavailableError, name unless installed?
|
||||
|
||||
@ -374,6 +385,14 @@ class Tap
|
||||
|
||||
Commands.rebuild_commands_completion_list
|
||||
clear_cache
|
||||
|
||||
return if !manual || !official?
|
||||
|
||||
untapped = self.class.untapped_official_taps
|
||||
return if untapped.include? name
|
||||
|
||||
untapped << name
|
||||
Homebrew::Settings.write :untapped, untapped.join(";")
|
||||
end
|
||||
|
||||
# True if the {#remote} of {Tap} is customized.
|
||||
@ -624,6 +643,12 @@ class Tap
|
||||
Pathname.glob TAP_DIRECTORY/"*/*/cmd"
|
||||
end
|
||||
|
||||
# An array of official taps that have been manually untapped
|
||||
sig { returns(T::Array[String]) }
|
||||
def self.untapped_official_taps
|
||||
Homebrew::Settings.read(:untapped)&.split(";") || []
|
||||
end
|
||||
|
||||
# @private
|
||||
def formula_file_to_name(file)
|
||||
"#{name}/#{file.basename(".rb")}"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user