penchant 0.2.12 → 0.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/bin/penchant CHANGED
@@ -45,6 +45,8 @@ class PenchantCLI < Thor
45
45
  method_options :switch_back => false
46
46
  desc "gemfile ENV", "Switch the gemfile environment, or rebuild the current environment if not given"
47
47
  def gemfile(env = get_current_env)
48
+ check_git_hooks!
49
+
48
50
  if env
49
51
  if options[:switch_back]
50
52
  puts "[penchant] Switching back, fallback: #{env}..."
@@ -93,9 +95,17 @@ class PenchantCLI < Thor
93
95
  out << "deployment" if gemfile.deployment?
94
96
  out.join(' ')
95
97
  end
98
+
99
+ def check_git_hooks!
100
+ if !Penchant::Hooks.installed?
101
+ puts "[penchant] git hooks not installed. Run script/install-git-hooks."
102
+ puts
103
+ end
104
+ end
96
105
  end
97
106
 
98
107
  default_task :gemfile
99
108
  end
100
109
 
101
110
  PenchantCLI.start
111
+
data/features/cli.feature CHANGED
@@ -27,4 +27,30 @@ Feature: CLI
27
27
  source :rubygems
28
28
  """
29
29
  And the output should include "No git"
30
-
30
+
31
+ @wip
32
+ Scenario: Run in a project where the git hooks are not set up
33
+ Given I have the file "tmp/Gemfile.penchant" with the content:
34
+ """
35
+ gem 'rake'
36
+ """
37
+ Given I have the file "tmp/script/hooks/pre-commit" with the content:
38
+ """
39
+ a penchant hook
40
+ """
41
+ When I run "bin/penchant gemfile remote" in the "tmp" directory
42
+ Then the output should include "git hooks not installed"
43
+
44
+ @wip
45
+ Scenario: Run in a project where git hooks are set up
46
+ Given I have the file "tmp/Gemfile.penchant" with the content:
47
+ """
48
+ gem 'rake'
49
+ """
50
+ Given I have the file "tmp/script/hooks/pre-commit" with the content:
51
+ """
52
+ a penchant hook
53
+ """
54
+ Given I have the symlink "tmp/.git/hooks/pre-commit" which points to "tmp/script/hooks/pre-commit"
55
+ When I run "bin/penchant gemfile remote" in the "tmp" directory
56
+ Then the output should not include "git hooks not installed"
@@ -0,0 +1,4 @@
1
+ Given /^I have the symlink "(.*?)" which points to "(.*?)"$/ do |source, target|
2
+ FileUtils.mkdir_p(File.dirname(source))
3
+ File.symlink(target, source)
4
+ end
@@ -0,0 +1,3 @@
1
+ Then /^the output should not include "(.*?)"$/ do |text|
2
+ @output.should_not include(text)
3
+ end
@@ -0,0 +1,21 @@
1
+ require 'pathname'
2
+
3
+ module Penchant
4
+ class Hooks
5
+ HOOKS_DIR = 'script/hooks'
6
+ GIT_HOOKS_DIR = '.git/hooks'
7
+
8
+ def self.installed?
9
+ if File.directory?(HOOKS_DIR)
10
+ Dir[File.join(HOOKS_DIR, '*')].each do |file|
11
+ target = File.join(GIT_HOOKS_DIR, File.basename(file))
12
+ return false if !File.symlink?(target)
13
+ return false if !File.expand_path(File.readlink(target)) == File.expand_path(file)
14
+ end
15
+
16
+ true
17
+ end
18
+ end
19
+ end
20
+ end
21
+
@@ -1,3 +1,3 @@
1
1
  module Penchant
2
- VERSION = "0.2.12"
2
+ VERSION = "0.2.13"
3
3
  end
data/lib/penchant.rb CHANGED
@@ -2,4 +2,5 @@ module Penchant
2
2
  autoload :Gemfile, 'penchant/gemfile'
3
3
  autoload :Repo, 'penchant/repo'
4
4
  autoload :DotPenchant, 'penchant/dot_penchant'
5
+ autoload :Hooks, 'penchant/hooks'
5
6
  end
@@ -2,14 +2,25 @@
2
2
 
3
3
  msg=$(cat $1)
4
4
 
5
- OLD_GIT_DIR=$GIT_DIR
5
+ # wtf mac os x lion
6
+ if [ ! -z "$MY_RUBY_HOME" ]; then
7
+ PATH="$MY_RUBY_HOME/bin:$PATH"
8
+ fi
6
9
 
7
- if [[ "${msg}" != *"[ci skip]"* ]]; then
8
- if [ "$(penchant gemfile-env)" != "remote" ]; then
9
- penchant gemfile remote
10
- fi
10
+ if [ ! -z "$GEM_PATH" ]; then
11
+ oifs="$IFS"
12
+ while IFS=":" read -ra GEM_PATHS; do
13
+ FIXED_GEM_PATH=""
14
+ for i in "${GEM_PATHS[@]}"; do
15
+ FIXED_GEM_PATH="$FIXED_GEM_PATH:${i}/bin"
16
+ done
17
+ done <<< "$GEM_PATH"
18
+ IFS="$oifs"
19
+ PATH="$FIXED_GEM_PATH:$PATH"
20
+ fi
11
21
 
12
- bundle exec rake
22
+ if [[ "${msg}" != *"[ci skip]"* ]]; then
23
+ bundle exec rake --trace
13
24
  R=$?
14
25
  if [ $R -ne 0 ]; then exit $R; fi
15
26
  fi
@@ -1,4 +1,2 @@
1
1
  #!/bin/bash
2
2
 
3
- penchant gemfile remote --switch-back
4
-
@@ -1,4 +1,2 @@
1
1
  #!/bin/bash
2
2
 
3
- # this has been moved to commit-msg
4
-
@@ -4,6 +4,24 @@ msg=$(cat $1)
4
4
 
5
5
  OLD_GIT_DIR=$GIT_DIR
6
6
 
7
+ # lion appears to insert git paths before everything else. ensure rvm can
8
+ # bust through, at the very least.
9
+ if [ ! -z "$MY_RUBY_HOME" ]; then
10
+ PATH="$MY_RUBY_HOME/bin:$PATH"
11
+ fi
12
+
13
+ if [ ! -z "$GEM_PATH" ]; then
14
+ oifs="$IFS"
15
+ while IFS=":" read -ra GEM_PATHS; do
16
+ FIXED_GEM_PATH=""
17
+ for i in "${GEM_PATHS[@]}"; do
18
+ FIXED_GEM_PATH="$FIXED_GEM_PATH:${i}/bin"
19
+ done
20
+ done <<< "$GEM_PATH"
21
+ IFS="$oifs"
22
+ PATH="$FIXED_GEM_PATH:$PATH"
23
+ fi
24
+
7
25
  if [[ "${msg}" != *"[ci skip]"* ]]; then
8
26
  if [ "$(penchant gemfile-env)" != "remote" ]; then
9
27
  unset GIT_DIR
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.12
4
+ version: 0.2.13
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-23 00:00:00.000000000 Z
12
+ date: 2012-07-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -144,11 +144,13 @@ files:
144
144
  - features/ruby_gemfile.feature
145
145
  - features/step_definitions/given/i_am_on_the_linux_platform.rb
146
146
  - features/step_definitions/given/i_have_the_file_with_content.rb
147
+ - features/step_definitions/given/i_have_the_symlink_git_hooks_pre_commit_which_points_to_script_hooks_pre_commit.rb
147
148
  - features/step_definitions/then/i_should_get_the_following_environments.rb
148
149
  - features/step_definitions/then/i_should_get_the_following_repositories.rb
149
150
  - features/step_definitions/then/the_file_gemfile_should_have_the_following_stripped_content.rb
150
151
  - features/step_definitions/then/the_file_should_have_content.rb
151
152
  - features/step_definitions/then/the_output_should_include.rb
153
+ - features/step_definitions/then/the_output_should_not_include_git_hooks_not_installed.rb
152
154
  - features/step_definitions/when/i_rebuild_the_gemfile_for_local_mode.rb
153
155
  - features/step_definitions/when/i_rebuild_the_gemfile_switching_back.rb
154
156
  - features/step_definitions/when/i_rebuild_the_gemfile_with_deployment.rb
@@ -160,6 +162,7 @@ files:
160
162
  - lib/penchant.rb
161
163
  - lib/penchant/dot_penchant.rb
162
164
  - lib/penchant/gemfile.rb
165
+ - lib/penchant/hooks.rb
163
166
  - lib/penchant/repo.rb
164
167
  - lib/penchant/version.rb
165
168
  - penchant.gemspec
@@ -193,7 +196,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
193
196
  version: '0'
194
197
  segments:
195
198
  - 0
196
- hash: 1854452012171480691
199
+ hash: 3150302730892137404
197
200
  required_rubygems_version: !ruby/object:Gem::Requirement
198
201
  none: false
199
202
  requirements:
@@ -202,10 +205,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
202
205
  version: '0'
203
206
  segments:
204
207
  - 0
205
- hash: 1854452012171480691
208
+ hash: 3150302730892137404
206
209
  requirements: []
207
210
  rubyforge_project: penchant
208
- rubygems_version: 1.8.24
211
+ rubygems_version: 1.8.23
209
212
  signing_key:
210
213
  specification_version: 3
211
214
  summary: Things I do for my Rails projects to get up to speed in new environments
@@ -216,11 +219,13 @@ test_files:
216
219
  - features/ruby_gemfile.feature
217
220
  - features/step_definitions/given/i_am_on_the_linux_platform.rb
218
221
  - features/step_definitions/given/i_have_the_file_with_content.rb
222
+ - features/step_definitions/given/i_have_the_symlink_git_hooks_pre_commit_which_points_to_script_hooks_pre_commit.rb
219
223
  - features/step_definitions/then/i_should_get_the_following_environments.rb
220
224
  - features/step_definitions/then/i_should_get_the_following_repositories.rb
221
225
  - features/step_definitions/then/the_file_gemfile_should_have_the_following_stripped_content.rb
222
226
  - features/step_definitions/then/the_file_should_have_content.rb
223
227
  - features/step_definitions/then/the_output_should_include.rb
228
+ - features/step_definitions/then/the_output_should_not_include_git_hooks_not_installed.rb
224
229
  - features/step_definitions/when/i_rebuild_the_gemfile_for_local_mode.rb
225
230
  - features/step_definitions/when/i_rebuild_the_gemfile_switching_back.rb
226
231
  - features/step_definitions/when/i_rebuild_the_gemfile_with_deployment.rb