aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMartin Afanasjew2016-06-13 02:57:35 +0200
committerMartin Afanasjew2016-06-19 22:12:34 +0200
commit595487796273467fdca73ab0adadf040bd664c6d (patch)
tree09379fad3c2b1f84ec29a6361376a1cf65f8847b /Library
parentd7b6e9bba92ccc5884dcb9dd0859d16e2bf3fe9c (diff)
downloadbrew-595487796273467fdca73ab0adadf040bd664c6d.tar.bz2
diagnostic: use 'Utils.git_version', simplify code
Prefer `Utils.git_version` instead of duplicating version detection logic. Decouple unnecessary conflated availability and version checks. Closes #351. Signed-off-by: Martin Afanasjew <martin@afanasjew.de>
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/diagnostic.rb26
1 files changed, 12 insertions, 14 deletions
diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb
index b46e1c0f1..8bce63559 100644
--- a/Library/Homebrew/diagnostic.rb
+++ b/Library/Homebrew/diagnostic.rb
@@ -743,15 +743,15 @@ module Homebrew
EOS
end
- def __check_git_version
+ def check_git_version
# https://help.github.com/articles/https-cloning-errors
- `git --version`.chomp =~ /git version ((?:\d+\.?)+)/
- return unless $1 && Version.new($1) < Version.new("1.7.10")
+ return unless Utils.git_available?
+ return unless Version.new(Utils.git_version) < Version.new("1.7.10")
git = Formula["git"]
git_upgrade_cmd = git.any_version_installed? ? "upgrade" : "install"
<<-EOS.undent
- An outdated version of Git was detected in your PATH.
+ An outdated version (#{Utils.git_version}) of Git was detected in your PATH.
Git 1.7.10 or newer is required to perform checkouts over HTTPS from GitHub.
Please upgrade:
brew #{git_upgrade_cmd} git
@@ -759,16 +759,14 @@ module Homebrew
end
def check_for_git
- if Utils.git_available?
- __check_git_version
- else
- <<-EOS.undent
- Git could not be found in your PATH.
- Homebrew uses Git for several internal functions, and some formulae use Git
- checkouts instead of stable tarballs. You may want to install Git:
- brew install git
- EOS
- end
+ return if Utils.git_available?
+
+ <<-EOS.undent
+ Git could not be found in your PATH.
+ Homebrew uses Git for several internal functions, and some formulae use Git
+ checkouts instead of stable tarballs. You may want to install Git:
+ brew install git
+ EOS
end
def check_git_newline_settings