git_available?: cache the result

This commit is contained in:
Xu Cheng 2015-09-08 15:09:15 +08:00
parent 1b531492ca
commit 4529df1246

View File

@ -1,11 +1,12 @@
module Utils
def self.git_available?
return @git if instance_variable_defined?(:@git)
git = which("git")
# git isn't installed by older Xcodes
return false if git.nil?
return @git = false if git.nil?
# /usr/bin/git is a popup stub when Xcode/CLT aren't installed, so bail out
return false if git == "/usr/bin/git" && !OS::Mac.has_apple_developer_tools?
true
return @git = false if git == "/usr/bin/git" && !OS::Mac.has_apple_developer_tools?
@git = true
end
def self.ensure_git_installed!