Tightened up git checking to check for a minimum installed version of
Git.
This commit is contained in:
@@ -8,6 +8,7 @@ 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'
|
||||
|
||||
@@ -3,6 +3,12 @@ module Homesick
|
||||
module Actions
|
||||
# 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('.')
|
||||
|
||||
# TODO: move this to be more like thor's template, empty_directory, etc
|
||||
def git_clone(repo, config = {})
|
||||
config ||= {}
|
||||
|
||||
@@ -20,8 +20,8 @@ module Homesick
|
||||
def initialize(args = [], options = {}, config = {})
|
||||
super
|
||||
# Check if git is installed
|
||||
unless `git --version`.size > 0
|
||||
say_status :error, 'Git must be installed to use Homesick', :red
|
||||
unless `git --version` =~ GIT_VERSION_PATTERN
|
||||
say_status :error, "Git version >= #{Homesick::Actions::GitActions::STRING} must be installed to use Homesick", :red
|
||||
exit(1)
|
||||
end
|
||||
# Hack in support for diffing symlinks
|
||||
|
||||
Reference in New Issue
Block a user