mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
diagnostic: add check for broken taps
Detect half-baked core taps that show up on a fairly regular basis (e.g. #11465). The logic is simple enough: Since an improper tap wouldn't have a complete Git config, and is always somewhere below `HOMEBREW_REPOSITORY`, any Git operation would look at the Brew repo instead. We simply need to test for any of: 1. Empty tap origin 2. Empty tap HEAD 3. Tap HEAD == Brew HEAD
This commit is contained in:
parent
5115cc25fa
commit
c7bbb904e8
@ -147,6 +147,27 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def broken_tap_msg(tap)
|
||||||
|
<<~EOS
|
||||||
|
#{tap.full_name} was not tapped properly.
|
||||||
|
To fix:
|
||||||
|
rm -rf "#{tap.path}"
|
||||||
|
brew tap #{tap.name}
|
||||||
|
EOS
|
||||||
|
end
|
||||||
|
|
||||||
|
def broken_tap(tap)
|
||||||
|
return unless Utils::Git.available?
|
||||||
|
return unless HOMEBREW_REPOSITORY.git?
|
||||||
|
|
||||||
|
return broken_tap_msg(tap) if tap.remote.blank?
|
||||||
|
|
||||||
|
tap_head = tap.git_head
|
||||||
|
return broken_tap_msg(tap) if tap_head.blank?
|
||||||
|
|
||||||
|
return broken_tap_msg(tap) if tap_head == HOMEBREW_REPOSITORY.git_head
|
||||||
|
end
|
||||||
|
|
||||||
def check_for_installed_developer_tools
|
def check_for_installed_developer_tools
|
||||||
return if DevelopmentTools.installed?
|
return if DevelopmentTools.installed?
|
||||||
|
|
||||||
@ -558,15 +579,16 @@ module Homebrew
|
|||||||
examine_git_origin(HOMEBREW_REPOSITORY, Homebrew::EnvConfig.brew_git_remote)
|
examine_git_origin(HOMEBREW_REPOSITORY, Homebrew::EnvConfig.brew_git_remote)
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_coretap_git_origin
|
def check_coretap_integrity
|
||||||
examine_git_origin(CoreTap.instance.path, Homebrew::EnvConfig.core_git_remote)
|
coretap = CoreTap.instance
|
||||||
|
broken_tap(coretap) || examine_git_origin(coretap.path, Homebrew::EnvConfig.core_git_remote)
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_casktap_git_origin
|
def check_casktap_integrity
|
||||||
default_cask_tap = Tap.default_cask_tap
|
default_cask_tap = Tap.default_cask_tap
|
||||||
return unless default_cask_tap.installed?
|
return unless default_cask_tap.installed?
|
||||||
|
|
||||||
examine_git_origin(default_cask_tap.path, default_cask_tap.remote)
|
broken_tap(default_cask_tap) || examine_git_origin(default_cask_tap.path, default_cask_tap.remote)
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { returns(T.nilable(String)) }
|
sig { returns(T.nilable(String)) }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user