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 = OFFICIAL_CMD_TAPS.find { |_, cmds| cmds.include?(cmd) }
|
||||||
possible_tap = Tap.fetch(possible_tap.first) if possible_tap
|
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
|
# Unset HOMEBREW_HELP to avoid confusing the tap
|
||||||
with_env HOMEBREW_HELP: nil do
|
with_env HOMEBREW_HELP: nil do
|
||||||
|
|||||||
@ -99,8 +99,6 @@ module Homebrew
|
|||||||
begin
|
begin
|
||||||
return Cask::CaskLoader.load(name, config: Cask::Config.from_args(@parent))
|
return Cask::CaskLoader.load(name, config: Cask::Config.from_args(@parent))
|
||||||
rescue Cask::CaskUnavailableError => e
|
rescue Cask::CaskUnavailableError => e
|
||||||
retry if Tap.install_default_cask_tap_if_necessary
|
|
||||||
|
|
||||||
raise e if only == :cask
|
raise e if only == :cask
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -153,8 +153,14 @@ module Homebrew
|
|||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
formulae, casks = args.named.to_formulae_and_casks
|
begin
|
||||||
.partition { |formula_or_cask| formula_or_cask.is_a?(Formula) }
|
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?
|
if casks.any?
|
||||||
Cask::Cmd::Install.install_casks(
|
Cask::Cmd::Install.install_casks(
|
||||||
|
|||||||
@ -43,7 +43,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
tap.uninstall
|
tap.uninstall manual: true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -2,9 +2,11 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Tap
|
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 default_cask_tap.installed?
|
||||||
|
|
||||||
|
return false if !force && Tap.untapped_official_taps.include?(default_cask_tap.name)
|
||||||
|
|
||||||
default_cask_tap.install
|
default_cask_tap.install
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|||||||
@ -67,8 +67,8 @@ class Tap
|
|||||||
@default_cask_tap ||= fetch("Homebrew", "cask")
|
@default_cask_tap ||= fetch("Homebrew", "cask")
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { returns(T::Boolean) }
|
sig { params(force: T::Boolean).returns(T::Boolean) }
|
||||||
def self.install_default_cask_tap_if_necessary
|
def self.install_default_cask_tap_if_necessary(force: false)
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -326,6 +326,17 @@ class Tap
|
|||||||
.update_from_formula_names!(formula_names)
|
.update_from_formula_names!(formula_names)
|
||||||
end
|
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 if clone_target
|
||||||
return unless private?
|
return unless private?
|
||||||
return if quiet
|
return if quiet
|
||||||
@ -352,7 +363,7 @@ class Tap
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Uninstall this {Tap}.
|
# Uninstall this {Tap}.
|
||||||
def uninstall
|
def uninstall(manual: false)
|
||||||
require "descriptions"
|
require "descriptions"
|
||||||
raise TapUnavailableError, name unless installed?
|
raise TapUnavailableError, name unless installed?
|
||||||
|
|
||||||
@ -374,6 +385,14 @@ class Tap
|
|||||||
|
|
||||||
Commands.rebuild_commands_completion_list
|
Commands.rebuild_commands_completion_list
|
||||||
clear_cache
|
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
|
end
|
||||||
|
|
||||||
# True if the {#remote} of {Tap} is customized.
|
# True if the {#remote} of {Tap} is customized.
|
||||||
@ -624,6 +643,12 @@ class Tap
|
|||||||
Pathname.glob TAP_DIRECTORY/"*/*/cmd"
|
Pathname.glob TAP_DIRECTORY/"*/*/cmd"
|
||||||
end
|
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
|
# @private
|
||||||
def formula_file_to_name(file)
|
def formula_file_to_name(file)
|
||||||
"#{name}/#{file.basename(".rb")}"
|
"#{name}/#{file.basename(".rb")}"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user