brew doctor and GitDownloadStrategy now check for Git.

GitDownloadStrategy now fails if git isn't in the path, same as other
VCS strategies.

`brew doctor` will also warn if Git isn't installed.
This commit is contained in:
Adam Vandenberg 2010-07-09 07:13:19 -07:00
parent 4c2d3e1f7f
commit d637e0a139
2 changed files with 23 additions and 2 deletions

View File

@ -229,7 +229,7 @@ def check_user_path
end end
def check_which_pkg_config def check_which_pkg_config
binary = `which pkg-config`.chomp binary = `/usr/bin/which pkg-config`.chomp
return if binary.empty? return if binary.empty?
unless binary == "#{HOMEBREW_PREFIX}/bin/pkg-config" unless binary == "#{HOMEBREW_PREFIX}/bin/pkg-config"
@ -245,7 +245,7 @@ def check_which_pkg_config
end end
def check_pkg_config_paths def check_pkg_config_paths
binary = `which pkg-config`.chomp binary = `/usr/bin/which pkg-config`.chomp
return if binary.empty? return if binary.empty?
# Use the debug output to determine which paths are searched # Use the debug output to determine which paths are searched
@ -378,6 +378,22 @@ def check_for_multiple_volumes
end end
end end
def check_for_git
git = `/usr/bin/which git`.chomp
if git.empty?
puts <<-EOS.undent
"Git" was not found in your path.
Homebrew uses Git for several internal functions, and some formulae
(Erlang in particular) use Git checkouts instead of stable tarballs.
You may want to do:
brew install git
EOS
end
end
def brew_doctor def brew_doctor
read, write = IO.pipe read, write = IO.pipe
@ -401,6 +417,7 @@ def brew_doctor
check_for_dyld_vars check_for_dyld_vars
check_for_symlinked_cellar check_for_symlinked_cellar
check_for_multiple_volumes check_for_multiple_volumes
check_for_git
exit! 0 exit! 0
else else

View File

@ -236,6 +236,10 @@ class GitDownloadStrategy <AbstractDownloadStrategy
end end
def fetch def fetch
raise "You must install Git:\n\n"+
" brew install git\n" \
unless system "/usr/bin/which git"
ohai "Cloning #{@url}" ohai "Cloning #{@url}"
unless @clone.exist? unless @clone.exist?
safe_system 'git', 'clone', @url, @clone # indeed, leave it verbose safe_system 'git', 'clone', @url, @clone # indeed, leave it verbose