mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
diagnostic: Check for unnecessary Core and Cask taps
- If the user doesn't have `HOMEBREW_DEVELOPER` or `HOMEBREW_NO_INSTALL_FROM_API` set but does have `homebrew/core` or `homebrew/cask` taps installed this can cause problems with installing outdated software. - Hence, warn them in `brew doctor` if they have either of these taps installed, with instructions on how to remove them.
This commit is contained in:
parent
e6d84f43d2
commit
40f697e96e
@ -842,6 +842,32 @@ module Homebrew
|
|||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_for_unnecessary_core_tap
|
||||||
|
return if ENV["HOMEBREW_DEVELOPER"]
|
||||||
|
return if ENV["HOMEBREW_NO_INSTALL_FROM_API"]
|
||||||
|
return unless CoreTap.instance.installed?
|
||||||
|
|
||||||
|
<<~EOS
|
||||||
|
You have an unnecessary local Core tap!
|
||||||
|
This can cause problems installing up-to-date formulae.
|
||||||
|
Please remove it by running:
|
||||||
|
brew untap #{CoreTap.instance.name}
|
||||||
|
EOS
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_for_unnecessary_cask_tap
|
||||||
|
return if ENV["HOMEBREW_DEVELOPER"]
|
||||||
|
return if ENV["HOMEBREW_NO_INSTALL_FROM_API"]
|
||||||
|
return unless (cask_tap = Tap.fetch("homebrew", "cask")).installed?
|
||||||
|
|
||||||
|
<<~EOS
|
||||||
|
You have an unnecessary local Cask tap.
|
||||||
|
This can cause problems installing up-to-date casks.
|
||||||
|
Please remove it by running:
|
||||||
|
brew untap #{cask_tap.name}
|
||||||
|
EOS
|
||||||
|
end
|
||||||
|
|
||||||
def check_cask_software_versions
|
def check_cask_software_versions
|
||||||
add_info "Homebrew Version", HOMEBREW_VERSION
|
add_info "Homebrew Version", HOMEBREW_VERSION
|
||||||
add_info "macOS", MacOS.full_version
|
add_info "macOS", MacOS.full_version
|
||||||
|
@ -114,4 +114,24 @@ describe Homebrew::Diagnostic::Checks do
|
|||||||
expect(checks.check_homebrew_prefix)
|
expect(checks.check_homebrew_prefix)
|
||||||
.to match("Your Homebrew's prefix is not #{Homebrew::DEFAULT_PREFIX}")
|
.to match("Your Homebrew's prefix is not #{Homebrew::DEFAULT_PREFIX}")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
specify "#check_for_unnecessary_core_tap" do
|
||||||
|
ENV.delete("HOMEBREW_DEVELOPER")
|
||||||
|
ENV.delete("HOMEBREW_NO_INSTALL_FROM_API")
|
||||||
|
|
||||||
|
allow(CoreTap).to receive(:installed?).and_return(true)
|
||||||
|
|
||||||
|
expect(checks.check_for_unnecessary_core_tap).to match("You have an unnecessary local Core tap")
|
||||||
|
end
|
||||||
|
|
||||||
|
specify "#check_for_unnecessary_cask_tap" do
|
||||||
|
ENV.delete("HOMEBREW_DEVELOPER")
|
||||||
|
ENV.delete("HOMEBREW_NO_INSTALL_FROM_API")
|
||||||
|
|
||||||
|
cask_tap = Tap.new("homebrew", "cask")
|
||||||
|
allow(Tap).to receive(:fetch).with("homebrew", "cask").and_return(cask_tap)
|
||||||
|
allow(cask_tap).to receive(:installed?).and_return(true)
|
||||||
|
|
||||||
|
expect(checks.check_for_unnecessary_cask_tap).to match("unnecessary local Cask tap")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user