Added tests for a minimumGit version of 1.8.0.
This commit is contained in:
@@ -4,10 +4,23 @@ module Homesick
|
||||
# Git-related helper methods for Homesick
|
||||
module GitActions
|
||||
# Information on the minimum git version required for Homesick
|
||||
MAJOR = 2
|
||||
MINOR = 0
|
||||
PATCH = 0
|
||||
STRING = [MAJOR, MINOR, PATCH].compact.join('.')
|
||||
MIN_VERSION = {
|
||||
major: 1,
|
||||
minor: 8,
|
||||
patch: 0
|
||||
}
|
||||
STRING = MIN_VERSION.values.join('.')
|
||||
|
||||
def version_check
|
||||
info = `git --version`.scan(/(\d+)\.(\d+)\.(\d+)/).flatten.map(&:to_i)
|
||||
return false unless info.count == 3
|
||||
current_version = Hash[ [:major, :minor, :patch].zip(info) ]
|
||||
return true if current_version.eql?(MIN_VERSION)
|
||||
current_version.each do |k,v|
|
||||
return true if v > MIN_VERSION[k]
|
||||
end
|
||||
false
|
||||
end
|
||||
|
||||
# TODO: move this to be more like thor's template, empty_directory, etc
|
||||
def git_clone(repo, config = {})
|
||||
|
||||
@@ -20,7 +20,7 @@ module Homesick
|
||||
def initialize(args = [], options = {}, config = {})
|
||||
super
|
||||
# Check if git is installed
|
||||
unless `git --version` =~ GIT_VERSION_PATTERN
|
||||
unless version_check
|
||||
say_status :error, "Git version >= #{Homesick::Actions::GitActions::STRING} must be installed to use Homesick", :red
|
||||
exit(1)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user