doctor: use Utils.git_available? instead of git?
This commit is contained in:
parent
bff03ee5ba
commit
c8efb05826
@ -59,14 +59,6 @@ class Checks
|
||||
def inject_file_list(list, str)
|
||||
list.inject(str) { |s, f| s << " #{f}\n" }
|
||||
end
|
||||
|
||||
# Git will always be on PATH because of the wrapper script in
|
||||
# Library/ENV/scm, so we check if there is a *real*
|
||||
# git here to avoid multiple warnings.
|
||||
def git?
|
||||
return @git if instance_variable_defined?(:@git)
|
||||
@git = system "git --version >/dev/null 2>&1"
|
||||
end
|
||||
############# END HELPERS
|
||||
|
||||
# Sorry for the lack of an indent here, the diff would have been unreadable.
|
||||
@ -884,7 +876,7 @@ class Checks
|
||||
end
|
||||
|
||||
def check_for_git
|
||||
if git?
|
||||
if Utils.git_available?
|
||||
__check_git_version
|
||||
else <<-EOS.undent
|
||||
Git could not be found in your PATH.
|
||||
@ -896,7 +888,7 @@ class Checks
|
||||
end
|
||||
|
||||
def check_git_newline_settings
|
||||
return unless git?
|
||||
return unless Utils.git_available?
|
||||
|
||||
autocrlf = `git config --get core.autocrlf`.chomp
|
||||
|
||||
@ -914,7 +906,7 @@ class Checks
|
||||
end
|
||||
|
||||
def check_git_origin
|
||||
return unless git? && (HOMEBREW_REPOSITORY/".git").exist?
|
||||
return if !Utils.git_available? || !(HOMEBREW_REPOSITORY/".git").exist?
|
||||
|
||||
origin = Homebrew.git_origin
|
||||
|
||||
@ -1026,7 +1018,7 @@ class Checks
|
||||
end
|
||||
|
||||
def check_git_status
|
||||
return unless git?
|
||||
return unless Utils.git_available?
|
||||
HOMEBREW_REPOSITORY.cd do
|
||||
unless `git status --untracked-files=all --porcelain -- Library/Homebrew/ 2>/dev/null`.chomp.empty?
|
||||
<<-EOS.undent_________________________________________________________72
|
||||
@ -1120,7 +1112,7 @@ class Checks
|
||||
end
|
||||
|
||||
def check_for_outdated_homebrew
|
||||
return unless git?
|
||||
return unless Utils.git_available?
|
||||
HOMEBREW_REPOSITORY.cd do
|
||||
if File.directory? ".git"
|
||||
local = `git rev-parse -q --verify refs/remotes/origin/master`.chomp
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
module Utils
|
||||
def self.git_available?
|
||||
return @git if instance_variable_defined?(:@git)
|
||||
git = which("git")
|
||||
# check git in original path in case it's the wrapper script of Library/ENV/scm
|
||||
git = which("git", ORIGINAL_PATHS.join(File::PATH_SEPARATOR))
|
||||
# git isn't installed by older Xcodes
|
||||
return @git = false if git.nil?
|
||||
# /usr/bin/git is a popup stub when Xcode/CLT aren't installed, so bail out
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user