Merge pull request #15341 from issyl0/brew-doctor-unnecessary-core-taps

diagnostic: Check for unnecessary Core and Cask taps
This commit is contained in:
Issy Long 2023-04-30 19:25:00 +01:00 committed by GitHub
commit 01e0c20d01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 0 deletions

View File

@ -842,6 +842,36 @@ module Homebrew
EOS
end
def check_for_unnecessary_core_tap
return if Homebrew::EnvConfig.developer?
return if Homebrew::EnvConfig.no_install_from_api?
return if Homebrew::Settings.read("devcmdrun") == "true"
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 Homebrew::EnvConfig.developer?
return if Homebrew::EnvConfig.no_install_from_api?
return if Homebrew::Settings.read("devcmdrun") == "true"
cask_tap = Tap.fetch("homebrew", "cask")
return unless cask_tap.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
add_info "Homebrew Version", HOMEBREW_VERSION
add_info "macOS", MacOS.full_version

View File

@ -114,4 +114,24 @@ describe Homebrew::Diagnostic::Checks do
expect(checks.check_homebrew_prefix)
.to match("Your Homebrew's prefix is not #{Homebrew::DEFAULT_PREFIX}")
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