aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/utils/git.rb
diff options
context:
space:
mode:
authorXu Cheng2016-03-15 17:08:53 +0800
committerXu Cheng2016-03-21 19:07:38 +0800
commite0e277ecded0f557b72d14b367633282b3a8c433 (patch)
treef27f43a68bcb0bba8778d9d13af94c7c70b41eb8 /Library/Homebrew/utils/git.rb
parent8ca79a6df59a7d02ee379e5a766e9170bb26c797 (diff)
downloadbrew-e0e277ecded0f557b72d14b367633282b3a8c433.tar.bz2
utils/git: various improvement
* Use `ENV/scm/git` to check whether git is installed. * Use `brew install git` to enforce pre-install checks such as sudo check.
Diffstat (limited to 'Library/Homebrew/utils/git.rb')
-rw-r--r--Library/Homebrew/utils/git.rb13
1 files changed, 3 insertions, 10 deletions
diff --git a/Library/Homebrew/utils/git.rb b/Library/Homebrew/utils/git.rb
index 74ad49ffe..21bb7695c 100644
--- a/Library/Homebrew/utils/git.rb
+++ b/Library/Homebrew/utils/git.rb
@@ -1,27 +1,20 @@
module Utils
def self.git_available?
return @git if instance_variable_defined?(:@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
- return @git = false if git == "/usr/bin/git" && !OS::Mac.has_apple_developer_tools?
- @git = true
+ @git = quiet_system HOMEBREW_ENV_PATH/"scm/git", "--version"
end
def self.ensure_git_installed!
return if git_available?
- require "cmd/install"
begin
oh1 "Installing git"
- Homebrew.perform_preinstall_checks
- Homebrew.install_formula(Formulary.factory("git"))
+ safe_system HOMEBREW_BREW_FILE, "install", "git"
rescue
raise "Git is unavailable"
end
+ clear_git_available_cache
raise "Git is unavailable" unless git_available?
end