Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

diagnostic: check homebrew/core git remote. #2398

Merged
merged 1 commit into from
Mar 28, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 35 additions & 7 deletions Library/Homebrew/diagnostic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -794,31 +794,59 @@ def check_git_newline_settings
EOS
end

def check_git_origin
def check_brew_git_origin
return if !Utils.git_available? || !(HOMEBREW_REPOSITORY/".git").exist?

origin = HOMEBREW_REPOSITORY.git_origin

if origin.nil?
<<-EOS.undent
Missing git origin remote.
Missing Homebrew/brew git origin remote.

Without a correctly configured origin, Homebrew won't update
properly. You can solve this by adding the Homebrew remote:
cd #{HOMEBREW_REPOSITORY}
git remote add origin #{Formatter.url("https://github.com/Homebrew/brew.git")}
git -C "#{HOMEBREW_REPOSITORY}" remote add origin #{Formatter.url("https://github.com/Homebrew/brew.git")}
EOS
elsif origin !~ %r{Homebrew/brew(\.git)?$}
<<-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
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, located at:
#{Formatter.url("https://github.com/Homebrew/brew.git")}
origin remote to point at the main repository by running:
git -C "#{HOMEBREW_REPOSITORY}" remote add origin #{Formatter.url("https://github.com/Homebrew/brew.git")}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this -C option work with older gits?

Copy link
Contributor

@JCount JCount Mar 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks as if the option was added in the 1.8.5 release of git which came out on November 27, 2013. Hence, it probably isn't something we need to be too concerned with.

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
end
end
Expand Down