mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Allow for homebrew/core to be untapped
This commit is contained in:
parent
1cb0f0fbf2
commit
2760d981d3
@ -25,7 +25,7 @@ module Homebrew
|
||||
args = untap_args.parse
|
||||
|
||||
args.named.to_installed_taps.each do |tap|
|
||||
odie "Untapping #{tap} is not allowed" if tap.core_tap?
|
||||
odie "Untapping #{tap} is not allowed" if tap.core_tap? && !ENV["HOMEBREW_UNTAP_HOMEBREW_CORE"]
|
||||
|
||||
installed_tap_formulae = Formula.installed.select { |formula| formula.tap == tap }
|
||||
installed_tap_casks = Cask::Caskroom.casks.select { |cask| cask.tap == tap }
|
||||
|
@ -207,6 +207,7 @@ module Homebrew
|
||||
|
||||
def install_core_tap_if_necessary
|
||||
return if ENV["HOMEBREW_UPDATE_TEST"]
|
||||
return if ENV["HOMEBREW_UNTAP_HOMEBREW_CORE"]
|
||||
|
||||
core_tap = CoreTap.instance
|
||||
return if core_tap.installed?
|
||||
|
@ -46,6 +46,15 @@ class Dependency
|
||||
formula
|
||||
end
|
||||
|
||||
def unavailable_core_formula?
|
||||
to_formula
|
||||
false
|
||||
rescue CoreTapFormulaUnavailableError
|
||||
true
|
||||
rescue
|
||||
false
|
||||
end
|
||||
|
||||
def installed?
|
||||
to_formula.latest_version_installed?
|
||||
end
|
||||
@ -130,6 +139,8 @@ class Dependency
|
||||
|
||||
def action(dependent, dep, &block)
|
||||
catch(:action) do
|
||||
prune if dep.unavailable_core_formula?
|
||||
|
||||
if block
|
||||
yield dependent, dep
|
||||
elsif dep.optional? || dep.recommended?
|
||||
|
@ -221,6 +221,13 @@ class TapFormulaUnavailableError < FormulaUnavailableError
|
||||
end
|
||||
end
|
||||
|
||||
# Raised when a formula in a the core tap is unavailable.
|
||||
class CoreTapFormulaUnavailableError < TapFormulaUnavailableError
|
||||
def initialize(name)
|
||||
super CoreTap.instance, name
|
||||
end
|
||||
end
|
||||
|
||||
# Raised when a formula in a specific tap does not contain a formula class.
|
||||
class TapFormulaClassUnavailableError < TapFormulaUnavailableError
|
||||
include FormulaClassUnavailableErrorModule
|
||||
|
@ -361,6 +361,10 @@ module Formulary
|
||||
end
|
||||
|
||||
def get_formula(*)
|
||||
if !CoreTap.instance.installed? && ENV["HOMEBREW_UNTAP_HOMEBREW_CORE"]
|
||||
raise CoreTapFormulaUnavailableError, name
|
||||
end
|
||||
|
||||
raise FormulaUnavailableError, name
|
||||
end
|
||||
end
|
||||
|
@ -734,6 +734,7 @@ class CoreTap < Tap
|
||||
|
||||
def self.ensure_installed!
|
||||
return if instance.installed?
|
||||
return if ENV["HOMEBREW_UNTAP_HOMEBREW_CORE"]
|
||||
|
||||
safe_system HOMEBREW_BREW_FILE, "tap", instance.name
|
||||
end
|
||||
@ -748,9 +749,11 @@ class CoreTap < Tap
|
||||
end
|
||||
|
||||
# @private
|
||||
sig { void }
|
||||
def uninstall
|
||||
raise "Tap#uninstall is not available for CoreTap"
|
||||
sig { params(manual: T::Boolean).void }
|
||||
def uninstall(manual: false)
|
||||
raise "Tap#uninstall is not available for CoreTap" unless ENV["HOMEBREW_UNTAP_HOMEBREW_CORE"]
|
||||
|
||||
super
|
||||
end
|
||||
|
||||
# @private
|
||||
|
Loading…
x
Reference in New Issue
Block a user