force install of git hooks in gemfile.penchant if so desired
This commit is contained in:
parent
01ac9bf14e
commit
3761c79d25
10
README.md
10
README.md
@ -29,6 +29,9 @@ Yeah, it's a `Gemfile` with some extras:
|
||||
# Gemfile.penchant
|
||||
source :rubygems
|
||||
|
||||
# ensure git hooks are installed when a gemfile is processed, see below
|
||||
ensure_git_hooks!
|
||||
|
||||
gem 'rails', '3.2.3'
|
||||
# expands to:
|
||||
#
|
||||
@ -173,6 +176,13 @@ It runs `penchant gemfile remote` then runs `bundle exec rake`. Make sure your d
|
||||
tests and performs any other magic necessary before each commit. Your re-environmented Gemfile and Gemfile.lock will be added
|
||||
to your commit if they've changed.
|
||||
|
||||
### Ensuring git hooks get installed
|
||||
|
||||
I find that when I pull down new projects I never remember to install the git hooks, which involves an awkward running
|
||||
of `bundle exec rake` *after* I've already committed code. Since we have computers now, and they can be told to do things,
|
||||
you can add `ensure_git_hooks!` anywhere in your `Gemfile.penchant` to make sure the git hooks are symlinked to the ones
|
||||
in the `script/hooks` directory with every processing of `Gemfile.penchant`.
|
||||
|
||||
### Skipping all that Rake falderal?
|
||||
|
||||
Do it Travis CI style: stick `[ci skip]` in your commit message. That's why the meat of the git hooks resides in
|
||||
|
@ -19,9 +19,7 @@ class PenchantCLI < Thor
|
||||
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
|
||||
Penchant::Hooks.install!
|
||||
else
|
||||
puts "No git repository detected here. Skipping git hook installation..."
|
||||
end
|
||||
|
@ -28,7 +28,6 @@ Feature: CLI
|
||||
"""
|
||||
And the output should include "No git"
|
||||
|
||||
@wip
|
||||
Scenario: Run in a project where the git hooks are not set up
|
||||
Given I have the file "tmp/Gemfile.penchant" with the content:
|
||||
"""
|
||||
@ -41,7 +40,6 @@ Feature: CLI
|
||||
When I run "bin/penchant gemfile remote" in the "tmp" directory
|
||||
Then the output should include "git hooks not installed"
|
||||
|
||||
@wip
|
||||
Scenario: Run in a project where git hooks are set up
|
||||
Given I have the file "tmp/Gemfile.penchant" with the content:
|
||||
"""
|
||||
|
@ -278,3 +278,19 @@ Feature: Gemfiles
|
||||
gem "one", {:git=>"git://github.com/john/one.git"}
|
||||
"""
|
||||
|
||||
@mocha
|
||||
Scenario: Force installing of git hooks if the gemfile asks for it
|
||||
Given I expect git hooks to be installed
|
||||
Given I have the file "Gemfile.penchant" with the content:
|
||||
"""
|
||||
ensure_git_hooks!
|
||||
|
||||
gem 'one'
|
||||
"""
|
||||
When I rebuild the Gemfile for "local" mode
|
||||
Then the file "Gemfile" should have the following content:
|
||||
"""
|
||||
# generated by penchant, environment: local
|
||||
gem "one"
|
||||
"""
|
||||
|
||||
|
@ -0,0 +1,3 @@
|
||||
Given /^I expect git hooks to be installed$/ do
|
||||
Penchant::Hooks.expects(:install!)
|
||||
end
|
@ -163,6 +163,10 @@ module Penchant
|
||||
yield if !is_deployment
|
||||
end
|
||||
|
||||
def ensure_git_hooks!
|
||||
Penchant::Hooks.install!
|
||||
end
|
||||
|
||||
def os(*args)
|
||||
yield if args.include?(current_os)
|
||||
end
|
||||
|
@ -16,6 +16,14 @@ module Penchant
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
def self.install!
|
||||
puts "[penchant] installing git hooks"
|
||||
|
||||
Dir['script/hooks/*'].each do |hook|
|
||||
FileUtils.ln_sf File.join(Dir.pwd, hook), ".git/hooks/#{File.split(hook).last}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
module Penchant
|
||||
VERSION = "0.2.13"
|
||||
VERSION = "0.2.14"
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user