Merge pull request #2398 from MikeMcQuaid/doctor-check-homebrew-core

diagnostic: check homebrew/core git remote.
This commit is contained in:
Mike McQuaid 2017-03-28 19:34:45 +01:00 committed by GitHub
commit a543cb2f9e

View File

@ -794,31 +794,59 @@ module Homebrew
EOS EOS
end end
def check_git_origin def check_brew_git_origin
return if !Utils.git_available? || !(HOMEBREW_REPOSITORY/".git").exist? return if !Utils.git_available? || !(HOMEBREW_REPOSITORY/".git").exist?
origin = HOMEBREW_REPOSITORY.git_origin origin = HOMEBREW_REPOSITORY.git_origin
if origin.nil? if origin.nil?
<<-EOS.undent <<-EOS.undent
Missing git origin remote. Missing Homebrew/brew git origin remote.
Without a correctly configured origin, Homebrew won't update Without a correctly configured origin, Homebrew won't update
properly. You can solve this by adding the Homebrew remote: properly. You can solve this by adding the Homebrew remote:
cd #{HOMEBREW_REPOSITORY} git -C "#{HOMEBREW_REPOSITORY}" remote add origin #{Formatter.url("https://github.com/Homebrew/brew.git")}
git remote add origin #{Formatter.url("https://github.com/Homebrew/brew.git")}
EOS EOS
elsif origin !~ %r{Homebrew/brew(\.git)?$} elsif origin !~ %r{Homebrew/brew(\.git)?$}
<<-EOS.undent <<-EOS.undent
Suspicious git origin remote found. Suspicious Homebrew/brew git origin remote found.
With a non-standard origin, Homebrew won't pull updates from With a non-standard origin, Homebrew won't pull updates from
the main repository. The current git origin is: the main repository. The current git origin is:
#{origin} #{origin}
Unless you have compelling reasons, consider setting the Unless you have compelling reasons, consider setting the
origin remote to point at the main repository, located at: origin remote to point at the main repository by running:
#{Formatter.url("https://github.com/Homebrew/brew.git")} git -C "#{HOMEBREW_REPOSITORY}" remote add origin #{Formatter.url("https://github.com/Homebrew/brew.git")}
EOS
end
end
def check_coretap_git_origin
coretap_path = CoreTap.instance.path
return if !Utils.git_available? || !(coretap_path/".git").exist?
origin = coretap_path.git_origin
if origin.nil?
<<-EOS.undent
Missing #{CoreTap.instance} git origin remote.
Without a correctly configured origin, Homebrew won't update
properly. You can solve this by adding the Homebrew remote:
git -C "#{coretap_path}" remote add origin #{Formatter.url("https://github.com/Homebrew/homebrew-core.git")}
EOS
elsif origin !~ %r{Homebrew/homebrew-core(\.git)?$}
<<-EOS.undent
Suspicious #{CoreTap.instance} git origin remote found.
With a non-standard origin, Homebrew won't pull updates from
the main repository. The current git origin is:
#{origin}
Unless you have compelling reasons, consider setting the
origin remote to point at the main repository by running:
git -C "#{coretap_path}" remote add origin #{Formatter.url("https://github.com/Homebrew/homebrew-core.git")}
EOS EOS
end end
end end