add post-commit script
This commit is contained in:
parent
25f9f7e3fb
commit
9354fed2dc
|
@ -14,7 +14,10 @@ class PenchantCLI < Thor
|
||||||
def install
|
def install
|
||||||
directory 'template/script', options[:dir]
|
directory 'template/script', options[:dir]
|
||||||
Dir[File.join(options[:dir], '**/*')].each { |file| File.chmod(0755, file) }
|
Dir[File.join(options[:dir], '**/*')].each { |file| File.chmod(0755, file) }
|
||||||
FileUtils.ln_sf File.join(Dir.pwd, 'script/hooks/pre-commit'), '.git/hooks/pre-commit'
|
|
||||||
|
Dir['script/hooks/*'].each do |hook|
|
||||||
|
FileUtils.ln_sf File.join(Dir.pwd, hook), ".git/hooks/#{File.split(hook).last}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "convert", "Make an existing project Penchant-isized"
|
desc "convert", "Make an existing project Penchant-isized"
|
||||||
|
@ -49,7 +52,9 @@ class PenchantCLI < Thor
|
||||||
no_tasks do
|
no_tasks do
|
||||||
def get_current_env
|
def get_current_env
|
||||||
gemfile = Penchant::Gemfile.new
|
gemfile = Penchant::Gemfile.new
|
||||||
gemfile.environment
|
out = [ gemfile.environment ]
|
||||||
|
out << "deployment" if gemfile.deployment?
|
||||||
|
out.join(' ')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,11 @@ module Penchant
|
||||||
end
|
end
|
||||||
|
|
||||||
def environment
|
def environment
|
||||||
File.readlines(gemfile_path).first.strip[%r{environment: (.*)}, 1]
|
File.readlines(gemfile_path).first.strip[%r{environment: ([^, ]*)}, 1]
|
||||||
|
end
|
||||||
|
|
||||||
|
def deployment?
|
||||||
|
File.readlines(gemfile_path).first['deployment mode'] != nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def switch_to!(gemfile_env = nil, deployment = false)
|
def switch_to!(gemfile_env = nil, deployment = false)
|
||||||
|
|
|
@ -47,6 +47,17 @@ describe Penchant::Gemfile do
|
||||||
GEMFILE
|
GEMFILE
|
||||||
|
|
||||||
its(:environment) { should == environment }
|
its(:environment) { should == environment }
|
||||||
|
it { should_not be_deployment }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'deployment' do
|
||||||
|
let(:environment) { 'test' }
|
||||||
|
let(:data) { <<-GEMFILE }
|
||||||
|
# generated by penchant, environment: #{environment}, deployment mode
|
||||||
|
GEMFILE
|
||||||
|
|
||||||
|
its(:environment) { should == environment }
|
||||||
|
it { should be_deployment }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
penchant gemfile remote
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
OLD_GIT_DIR=$GIT_DIR
|
OLD_GIT_DIR=$GIT_DIR
|
||||||
|
|
||||||
if [ "$(penchant gemfile-env)" != "remote" ]; then
|
if [ "$(penchant gemfile-env)" != "remote deployment" ]; then
|
||||||
unset GIT_DIR
|
unset GIT_DIR
|
||||||
penchant gemfile remote --deployment
|
penchant gemfile remote --deployment
|
||||||
GIT_DIR=$OLD_GIT_DIR
|
GIT_DIR=$OLD_GIT_DIR
|
||||||
|
|
Loading…
Reference in New Issue