Added tests for a minimumGit version of 1.8.0.

This commit is contained in:
Jeremy Cook
2014-11-23 22:22:44 -05:00
parent a808f56caf
commit 7bd9759e81
4 changed files with 24 additions and 12 deletions

View File

@@ -8,7 +8,6 @@ require 'homesick/cli'
# Homesick's top-level module
module Homesick
GITHUB_NAME_REPO_PATTERN = /\A([A-Za-z0-9_-]+\/[A-Za-z0-9_-]+)\Z/
GIT_VERSION_PATTERN = /[#{Homesick::Actions::GitActions::MAJOR}-9]\.[#{Homesick::Actions::GitActions::MINOR}-9]\.[#{Homesick::Actions::GitActions::PATCH}-9]/
SUBDIR_FILENAME = '.homesick_subdir'
DEFAULT_CASTLE_NAME = 'dotfiles'

View File

@@ -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 = {})

View File

@@ -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