From 4529df1246a8db82ee07c4945f62b801ba6bf655 Mon Sep 17 00:00:00 2001 From: Xu Cheng Date: Tue, 8 Sep 2015 15:09:15 +0800 Subject: git_available?: cache the result --- Library/Homebrew/utils/git.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'Library/Homebrew/utils/git.rb') diff --git a/Library/Homebrew/utils/git.rb b/Library/Homebrew/utils/git.rb index 53057cd10..774a0a65f 100644 --- a/Library/Homebrew/utils/git.rb +++ b/Library/Homebrew/utils/git.rb @@ -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! -- cgit v1.2.3