ensure git hooks not installed if no git repo found
This commit is contained in:
parent
6679a65cdf
commit
64d4b5a323
19
bin/penchant
19
bin/penchant
@ -9,25 +9,32 @@ class PenchantCLI < Thor
|
||||
include Thor::Actions
|
||||
source_root File.expand_path('../..', __FILE__)
|
||||
|
||||
SCRIPT_DIR = 'script'
|
||||
CLONE_DIR = '..'
|
||||
|
||||
desc "install", "Copy the common scripts to the project"
|
||||
method_options :dir => 'script'
|
||||
method_options :dir => SCRIPT_DIR
|
||||
def install
|
||||
directory 'template/script', options[:dir]
|
||||
Dir[File.join(options[:dir], '**/*')].each { |file| File.chmod(0755, file) }
|
||||
|
||||
if File.directory?('.git')
|
||||
Dir['script/hooks/*'].each do |hook|
|
||||
FileUtils.ln_sf File.join(Dir.pwd, hook), ".git/hooks/#{File.split(hook).last}"
|
||||
end
|
||||
else
|
||||
puts "No git repository detected here. Skipping git hook installation..."
|
||||
end
|
||||
end
|
||||
|
||||
desc "update", "Update the installed scripts"
|
||||
method_options :dir => 'script'
|
||||
method_options :dir => SCRIPT_DIR
|
||||
def update
|
||||
install
|
||||
end
|
||||
|
||||
desc "convert", "Make an existing project Penchant-isized"
|
||||
method_options :dir => 'script'
|
||||
method_options :dir => SCRIPT_DIR
|
||||
def convert
|
||||
install
|
||||
FileUtils.mv 'Gemfile', 'Gemfile.penchant'
|
||||
@ -63,10 +70,10 @@ class PenchantCLI < Thor
|
||||
puts get_current_env
|
||||
end
|
||||
|
||||
desc "bootstrap [DIR = ..]", "Download all referred-to git repos to the specified directory"
|
||||
def bootstrap(dir = '..')
|
||||
desc "bootstrap [DIR = #{CLONE_DIR}]", "Download all referred-to git repos to the specified directory"
|
||||
def bootstrap(dir = CLONE_DIR)
|
||||
Penchant::Gemfile.defined_git_repos.each do |repo|
|
||||
puts "Cloning #{repo} to #{dir}."
|
||||
puts "Cloning #{repo} to #{dir}"
|
||||
repo.clone_to(dir)
|
||||
end
|
||||
end
|
||||
|
@ -16,3 +16,15 @@ Feature: CLI
|
||||
"""
|
||||
And the output should include "fallback: other"
|
||||
|
||||
Scenario: Try to convert a project, ignoring git hooks
|
||||
Given I have the file "tmp/Gemfile" with the content:
|
||||
"""
|
||||
source :rubygems
|
||||
"""
|
||||
When I run "bin/penchant convert" in the "tmp" directory
|
||||
Then the file "tmp/Gemfile.penchant" should have the following content:
|
||||
"""
|
||||
source :rubygems
|
||||
"""
|
||||
And the output should include "No git"
|
||||
|
||||
|
@ -2,7 +2,7 @@ require 'fakefs/safe'
|
||||
require 'penchant'
|
||||
require 'mocha'
|
||||
|
||||
World(Mocha::Standalone)
|
||||
World(Mocha::API)
|
||||
|
||||
Before('@fakefs') do
|
||||
FakeFS.activate!
|
||||
|
@ -1,3 +1,3 @@
|
||||
module Penchant
|
||||
VERSION = "0.2.11"
|
||||
VERSION = "0.2.12"
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user