penchant 0.2.13 → 0.2.14

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -29,6 +29,9 @@ Yeah, it's a `Gemfile` with some extras:
29
29
  # Gemfile.penchant
30
30
  source :rubygems
31
31
 
32
+ # ensure git hooks are installed when a gemfile is processed, see below
33
+ ensure_git_hooks!
34
+
32
35
  gem 'rails', '3.2.3'
33
36
  # expands to:
34
37
  #
@@ -173,6 +176,13 @@ It runs `penchant gemfile remote` then runs `bundle exec rake`. Make sure your d
173
176
  tests and performs any other magic necessary before each commit. Your re-environmented Gemfile and Gemfile.lock will be added
174
177
  to your commit if they've changed.
175
178
 
179
+ ### Ensuring git hooks get installed
180
+
181
+ I find that when I pull down new projects I never remember to install the git hooks, which involves an awkward running
182
+ of `bundle exec rake` *after* I've already committed code. Since we have computers now, and they can be told to do things,
183
+ you can add `ensure_git_hooks!` anywhere in your `Gemfile.penchant` to make sure the git hooks are symlinked to the ones
184
+ in the `script/hooks` directory with every processing of `Gemfile.penchant`.
185
+
176
186
  ### Skipping all that Rake falderal?
177
187
 
178
188
  Do it Travis CI style: stick `[ci skip]` in your commit message. That's why the meat of the git hooks resides in
data/bin/penchant CHANGED
@@ -19,9 +19,7 @@ class PenchantCLI < Thor
19
19
  Dir[File.join(options[:dir], '**/*')].each { |file| File.chmod(0755, file) }
20
20
 
21
21
  if File.directory?('.git')
22
- Dir['script/hooks/*'].each do |hook|
23
- FileUtils.ln_sf File.join(Dir.pwd, hook), ".git/hooks/#{File.split(hook).last}"
24
- end
22
+ Penchant::Hooks.install!
25
23
  else
26
24
  puts "No git repository detected here. Skipping git hook installation..."
27
25
  end
data/features/cli.feature CHANGED
@@ -28,7 +28,6 @@ Feature: CLI
28
28
  """
29
29
  And the output should include "No git"
30
30
 
31
- @wip
32
31
  Scenario: Run in a project where the git hooks are not set up
33
32
  Given I have the file "tmp/Gemfile.penchant" with the content:
34
33
  """
@@ -41,7 +40,6 @@ Feature: CLI
41
40
  When I run "bin/penchant gemfile remote" in the "tmp" directory
42
41
  Then the output should include "git hooks not installed"
43
42
 
44
- @wip
45
43
  Scenario: Run in a project where git hooks are set up
46
44
  Given I have the file "tmp/Gemfile.penchant" with the content:
47
45
  """
@@ -278,3 +278,19 @@ Feature: Gemfiles
278
278
  gem "one", {:git=>"git://github.com/john/one.git"}
279
279
  """
280
280
 
281
+ @mocha
282
+ Scenario: Force installing of git hooks if the gemfile asks for it
283
+ Given I expect git hooks to be installed
284
+ Given I have the file "Gemfile.penchant" with the content:
285
+ """
286
+ ensure_git_hooks!
287
+
288
+ gem 'one'
289
+ """
290
+ When I rebuild the Gemfile for "local" mode
291
+ Then the file "Gemfile" should have the following content:
292
+ """
293
+ # generated by penchant, environment: local
294
+ gem "one"
295
+ """
296
+
@@ -0,0 +1,3 @@
1
+ Given /^I expect git hooks to be installed$/ do
2
+ Penchant::Hooks.expects(:install!)
3
+ end
@@ -163,6 +163,10 @@ module Penchant
163
163
  yield if !is_deployment
164
164
  end
165
165
 
166
+ def ensure_git_hooks!
167
+ Penchant::Hooks.install!
168
+ end
169
+
166
170
  def os(*args)
167
171
  yield if args.include?(current_os)
168
172
  end
@@ -16,6 +16,14 @@ module Penchant
16
16
  true
17
17
  end
18
18
  end
19
+
20
+ def self.install!
21
+ puts "[penchant] installing git hooks"
22
+
23
+ Dir['script/hooks/*'].each do |hook|
24
+ FileUtils.ln_sf File.join(Dir.pwd, hook), ".git/hooks/#{File.split(hook).last}"
25
+ end
26
+ end
19
27
  end
20
28
  end
21
29
 
@@ -1,3 +1,3 @@
1
1
  module Penchant
2
- VERSION = "0.2.13"
2
+ VERSION = "0.2.14"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: penchant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.13
4
+ version: 0.2.14
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-24 00:00:00.000000000 Z
12
+ date: 2012-07-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -143,6 +143,7 @@ files:
143
143
  - features/gemfile.feature
144
144
  - features/ruby_gemfile.feature
145
145
  - features/step_definitions/given/i_am_on_the_linux_platform.rb
146
+ - features/step_definitions/given/i_expect_git_hooks_to_be_installed.rb
146
147
  - features/step_definitions/given/i_have_the_file_with_content.rb
147
148
  - features/step_definitions/given/i_have_the_symlink_git_hooks_pre_commit_which_points_to_script_hooks_pre_commit.rb
148
149
  - features/step_definitions/then/i_should_get_the_following_environments.rb
@@ -196,7 +197,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
196
197
  version: '0'
197
198
  segments:
198
199
  - 0
199
- hash: 3150302730892137404
200
+ hash: -4027868368802670317
200
201
  required_rubygems_version: !ruby/object:Gem::Requirement
201
202
  none: false
202
203
  requirements:
@@ -205,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
205
206
  version: '0'
206
207
  segments:
207
208
  - 0
208
- hash: 3150302730892137404
209
+ hash: -4027868368802670317
209
210
  requirements: []
210
211
  rubyforge_project: penchant
211
212
  rubygems_version: 1.8.23
@@ -218,6 +219,7 @@ test_files:
218
219
  - features/gemfile.feature
219
220
  - features/ruby_gemfile.feature
220
221
  - features/step_definitions/given/i_am_on_the_linux_platform.rb
222
+ - features/step_definitions/given/i_expect_git_hooks_to_be_installed.rb
221
223
  - features/step_definitions/given/i_have_the_file_with_content.rb
222
224
  - features/step_definitions/given/i_have_the_symlink_git_hooks_pre_commit_which_points_to_script_hooks_pre_commit.rb
223
225
  - features/step_definitions/then/i_should_get_the_following_environments.rb