overcommit 0.30.0 → 0.32.0

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.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/config/default.yml +123 -93
  3. data/lib/overcommit/configuration.rb +24 -2
  4. data/lib/overcommit/configuration_validator.rb +28 -1
  5. data/lib/overcommit/constants.rb +7 -5
  6. data/lib/overcommit/exceptions.rb +6 -0
  7. data/lib/overcommit/git_repo.rb +6 -0
  8. data/lib/overcommit/hook/base.rb +22 -4
  9. data/lib/overcommit/hook/commit_msg/capitalized_subject.rb +1 -1
  10. data/lib/overcommit/hook/commit_msg/message_format.rb +27 -0
  11. data/lib/overcommit/hook/pre_commit/base.rb +17 -8
  12. data/lib/overcommit/hook/pre_commit/berksfile_check.rb +3 -1
  13. data/lib/overcommit/hook/pre_commit/bundle_check.rb +3 -1
  14. data/lib/overcommit/hook/pre_commit/es_lint.rb +10 -0
  15. data/lib/overcommit/hook/pre_commit/execute_permissions.rb +10 -0
  16. data/lib/overcommit/hook/pre_commit/forbidden_branches.rb +24 -0
  17. data/lib/overcommit/hook/pre_commit/mdl.rb +23 -0
  18. data/lib/overcommit/hook/pre_commit/rubo_cop.rb +15 -4
  19. data/lib/overcommit/hook/pre_commit/scss_lint.rb +23 -10
  20. data/lib/overcommit/hook/pre_push/minitest.rb +4 -0
  21. data/lib/overcommit/hook/pre_push/protected_branches.rb +13 -6
  22. data/lib/overcommit/hook_context/base.rb +7 -0
  23. data/lib/overcommit/hook_context/pre_commit.rb +7 -0
  24. data/lib/overcommit/hook_context/pre_push.rb +12 -1
  25. data/lib/overcommit/hook_context/run_all.rb +1 -1
  26. data/lib/overcommit/hook_runner.rb +90 -41
  27. data/lib/overcommit/hook_signer.rb +1 -1
  28. data/lib/overcommit/message_processor.rb +20 -7
  29. data/lib/overcommit/os.rb +2 -2
  30. data/lib/overcommit/printer.rb +32 -8
  31. data/lib/overcommit/utils.rb +36 -0
  32. data/lib/overcommit/version.rb +3 -1
  33. data/template-dir/hooks/commit-msg +9 -1
  34. data/template-dir/hooks/overcommit-hook +9 -1
  35. data/template-dir/hooks/post-checkout +9 -1
  36. data/template-dir/hooks/post-commit +9 -1
  37. data/template-dir/hooks/post-merge +9 -1
  38. data/template-dir/hooks/post-rewrite +9 -1
  39. data/template-dir/hooks/pre-commit +9 -1
  40. data/template-dir/hooks/pre-push +9 -1
  41. data/template-dir/hooks/pre-rebase +9 -1
  42. metadata +21 -4
@@ -1,7 +1,7 @@
1
1
  module Overcommit
2
2
  # Responsible for loading the hooks the repository has configured and running
3
3
  # them, collecting and displaying the results.
4
- class HookRunner
4
+ class HookRunner # rubocop:disable Metrics/ClassLength
5
5
  # @param config [Overcommit::Configuration]
6
6
  # @param logger [Overcommit::Logger]
7
7
  # @param context [Overcommit::HookContext]
@@ -12,6 +12,10 @@ module Overcommit
12
12
  @context = context
13
13
  @printer = printer
14
14
  @hooks = []
15
+
16
+ @lock = Mutex.new
17
+ @resource = ConditionVariable.new
18
+ @slots_available = @config.concurrency
15
19
  end
16
20
 
17
21
  # Loads and runs the hooks registered for this {HookRunner}.
@@ -51,78 +55,123 @@ module Overcommit
51
55
  if @hooks.any?(&:enabled?)
52
56
  @printer.start_run
53
57
 
54
- interrupted = false
55
- run_failed = false
56
- run_warned = false
57
-
58
- @hooks.each do |hook|
59
- hook_status = run_hook(hook)
58
+ # Sort so hooks requiring fewer processors get queued first. This
59
+ # ensures we make better use of our available processors
60
+ @hooks_left = @hooks.sort_by { |hook| processors_for_hook(hook) }
61
+ @threads = Array.new(@config.concurrency) { Thread.new(&method(:consume)) }
60
62
 
61
- run_failed = true if hook_status == :fail
62
- run_warned = true if hook_status == :warn
63
-
64
- if hook_status == :interrupt
65
- # Stop running any more hooks and assume a bad result
66
- interrupted = true
67
- break
63
+ begin
64
+ InterruptHandler.disable_until_finished_or_interrupted do
65
+ @threads.each(&:join)
68
66
  end
67
+ rescue Interrupt
68
+ @printer.interrupt_triggered
69
+ # We received an interrupt on the main thread, so alert the
70
+ # remaining workers that an exception occurred
71
+ @interrupted = true
72
+ @threads.each { |thread| thread.raise Interrupt }
69
73
  end
70
74
 
71
- print_results(run_failed, run_warned, interrupted)
75
+ print_results
72
76
 
73
- !(run_failed || interrupted)
77
+ !(@failed || @interrupted)
74
78
  else
75
79
  @printer.nothing_to_run
76
80
  true # Run was successful
77
81
  end
78
82
  end
79
83
 
80
- # @param failed [Boolean]
81
- # @param warned [Boolean]
82
- # @param interrupted [Boolean]
83
- def print_results(failed, warned, interrupted)
84
- if interrupted
84
+ def consume
85
+ loop do
86
+ hook = @lock.synchronize { @hooks_left.pop }
87
+ break unless hook
88
+ run_hook(hook)
89
+ end
90
+ end
91
+
92
+ def wait_for_slot(hook)
93
+ @lock.synchronize do
94
+ slots_needed = processors_for_hook(hook)
95
+
96
+ loop do
97
+ if @slots_available >= slots_needed
98
+ @slots_available -= slots_needed
99
+
100
+ # Give another thread a chance since there are still slots available
101
+ @resource.signal if @slots_available > 0
102
+ break
103
+ elsif @slots_available > 0
104
+ # It's possible that another hook that requires fewer slots can be
105
+ # served, so give another a chance
106
+ @resource.signal
107
+
108
+ # Wait for a signal from another thread to try again
109
+ @resource.wait(@lock)
110
+ end
111
+ end
112
+ end
113
+ end
114
+
115
+ def release_slot(hook)
116
+ @lock.synchronize do
117
+ slots_released = processors_for_hook(hook)
118
+ @slots_available += slots_released
119
+
120
+ if @hooks_left.any?
121
+ # Signal once. `wait_for_slot` will perform additional signals if
122
+ # there are still slots available. This prevents us from sending out
123
+ # useless signals
124
+ @resource.signal
125
+ end
126
+ end
127
+ end
128
+
129
+ def processors_for_hook(hook)
130
+ hook.parallelize? ? hook.processors : @config.concurrency
131
+ end
132
+
133
+ def print_results
134
+ if @interrupted
85
135
  @printer.run_interrupted
86
- elsif failed
136
+ elsif @failed
87
137
  @printer.run_failed
88
- elsif warned
138
+ elsif @warned
89
139
  @printer.run_warned
90
140
  else
91
141
  @printer.run_succeeded
92
142
  end
93
143
  end
94
144
 
95
- def run_hook(hook)
96
- return if should_skip?(hook)
97
-
98
- @printer.start_hook(hook)
99
-
145
+ def run_hook(hook) # rubocop:disable Metrics/CyclomaticComplexity
100
146
  status, output = nil, nil
101
147
 
102
148
  begin
103
- # Disable the interrupt handler during individual hook run so that
104
- # Ctrl-C actually stops the current hook from being run, but doesn't
105
- # halt the entire process.
106
- InterruptHandler.disable_until_finished_or_interrupted do
107
- status, output = hook.run_and_transform
108
- end
149
+ wait_for_slot(hook)
150
+ return if should_skip?(hook)
151
+
152
+ status, output = hook.run_and_transform
153
+ rescue Overcommit::Exceptions::MessageProcessingError => ex
154
+ status = :fail
155
+ output = ex.message
109
156
  rescue => ex
110
157
  status = :fail
111
158
  output = "Hook raised unexpected error\n#{ex.message}\n#{ex.backtrace.join("\n")}"
112
- rescue Interrupt
113
- # At this point, interrupt has been handled and protection is back in
114
- # effect thanks to the InterruptHandler.
115
- status = :interrupt
116
- output = 'Hook was interrupted by Ctrl-C; restoring repo state...'
117
159
  end
118
160
 
119
- @printer.end_hook(hook, status, output)
161
+ @failed = true if status == :fail
162
+ @warned = true if status == :warn
163
+
164
+ @printer.end_hook(hook, status, output) unless @interrupted
120
165
 
121
166
  status
167
+ rescue Interrupt
168
+ @interrupted = true
169
+ ensure
170
+ release_slot(hook)
122
171
  end
123
172
 
124
173
  def should_skip?(hook)
125
- return true unless hook.enabled?
174
+ return true if @interrupted || !hook.enabled?
126
175
 
127
176
  if hook.skip?
128
177
  if hook.required?
@@ -5,7 +5,7 @@ module Overcommit
5
5
 
6
6
  # We don't want to include the skip setting as it is set by Overcommit
7
7
  # itself
8
- IGNORED_CONFIG_KEYS = %w[skip]
8
+ IGNORED_CONFIG_KEYS = %w[skip].freeze
9
9
 
10
10
  # @param hook_name [String] name of the hook
11
11
  # @param config [Overcommit::Configuration]
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Overcommit
2
4
  # Utility class that encapsulates the handling of hook messages and whether
3
5
  # they affect lines the user has modified or not.
@@ -6,10 +8,12 @@ module Overcommit
6
8
  # output tuple from an array of {Overcommit::Hook::Message}s, respecting the
7
9
  # configuration settings for the given hook.
8
10
  class MessageProcessor
9
- ERRORS_MODIFIED_HEADER = 'Errors on modified lines:'
10
- WARNINGS_MODIFIED_HEADER = 'Warnings on modified lines:'
11
- ERRORS_UNMODIFIED_HEADER = "Errors on lines you didn't modify:"
12
- WARNINGS_UNMODIFIED_HEADER = "Warnings on lines you didn't modify:"
11
+ ERRORS_MODIFIED_HEADER = 'Errors on modified lines:'.freeze
12
+ WARNINGS_MODIFIED_HEADER = 'Warnings on modified lines:'.freeze
13
+ ERRORS_UNMODIFIED_HEADER = "Errors on lines you didn't modify:".freeze
14
+ WARNINGS_UNMODIFIED_HEADER = "Warnings on lines you didn't modify:".freeze
15
+ ERRORS_GENERIC_HEADER = 'Errors:'.freeze
16
+ WARNINGS_GENERIC_HEADER = 'Warnings:'.freeze
13
17
 
14
18
  # @param hook [Overcommit::Hook::Base]
15
19
  # @param unmodified_lines_setting [String] how to treat messages on
@@ -40,10 +44,19 @@ module Overcommit
40
44
  def handle_modified_lines(messages, status)
41
45
  messages = remove_ignored_messages(messages)
42
46
 
43
- messages_on_modified_lines, messages_on_unmodified_lines =
44
- messages.partition { |message| message_on_modified_line?(message) }
47
+ messages_with_line, generic_messages = messages.partition(&:line)
45
48
 
49
+ # Always print generic messages first
46
50
  output = print_messages(
51
+ generic_messages,
52
+ ERRORS_GENERIC_HEADER,
53
+ WARNINGS_GENERIC_HEADER
54
+ )
55
+
56
+ messages_on_modified_lines, messages_on_unmodified_lines =
57
+ messages_with_line.partition { |message| message_on_modified_line?(message) }
58
+
59
+ output += print_messages(
47
60
  messages_on_modified_lines,
48
61
  ERRORS_MODIFIED_HEADER,
49
62
  WARNINGS_MODIFIED_HEADER
@@ -54,7 +67,7 @@ module Overcommit
54
67
  WARNINGS_UNMODIFIED_HEADER
55
68
  )
56
69
 
57
- [transform_status(status, messages_on_modified_lines), output]
70
+ [transform_status(status, generic_messages + messages_on_modified_lines), output]
58
71
  end
59
72
 
60
73
  def transform_status(status, messages_on_modified_lines)
data/lib/overcommit/os.rb CHANGED
@@ -27,10 +27,10 @@ module Overcommit
27
27
  private
28
28
 
29
29
  def host_os
30
- @os ||= ::RbConfig::CONFIG['host_os']
30
+ @os ||= ::RbConfig::CONFIG['host_os'].freeze
31
31
  end
32
32
  end
33
33
 
34
- SEPARATOR = self.windows? ? '\\' : File::SEPARATOR
34
+ SEPARATOR = (windows? ? '\\' : File::SEPARATOR).freeze
35
35
  end
36
36
  end
@@ -1,5 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require 'monitor'
4
+
3
5
  module Overcommit
4
6
  # Provide a set of callbacks which can be executed as events occur during the
5
7
  # course of {HookRunner#run}.
@@ -9,6 +11,8 @@ module Overcommit
9
11
  def initialize(logger, context)
10
12
  @log = logger
11
13
  @context = context
14
+ @lock = Monitor.new # Need to use monitor so we can have re-entrant locks
15
+ synchronize_all_methods
12
16
  end
13
17
 
14
18
  # Executed at the very beginning of running the collection of hooks.
@@ -20,13 +24,6 @@ module Overcommit
20
24
  log.debug "✓ No applicable #{hook_script_name} hooks to run"
21
25
  end
22
26
 
23
- # Executed at the start of an individual hook run.
24
- def start_hook(hook)
25
- unless hook.quiet?
26
- print_header(hook)
27
- end
28
- end
29
-
30
27
  def hook_skipped(hook)
31
28
  log.warning "Skipping #{hook.name}"
32
29
  end
@@ -39,11 +36,16 @@ module Overcommit
39
36
  def end_hook(hook, status, output)
40
37
  # Want to print the header for quiet hooks only if the result wasn't good
41
38
  # so that the user knows what failed
42
- print_header(hook) if hook.quiet? && status != :pass
39
+ print_header(hook) if !hook.quiet? || status != :pass
43
40
 
44
41
  print_result(hook, status, output)
45
42
  end
46
43
 
44
+ def interrupt_triggered
45
+ log.newline
46
+ log.error 'Interrupt signal received. Stopping hooks...'
47
+ end
48
+
47
49
  # Executed when a hook run was interrupted/cancelled by user.
48
50
  def run_interrupted
49
51
  log.newline
@@ -108,5 +110,27 @@ module Overcommit
108
110
  def hook_script_name
109
111
  @context.hook_script_name
110
112
  end
113
+
114
+ # Get all public methods that were defined on this class and wrap them with
115
+ # synchronization locks so we ensure the output isn't interleaved amongst
116
+ # the various threads.
117
+ def synchronize_all_methods
118
+ methods = self.class.instance_methods - self.class.superclass.instance_methods
119
+
120
+ methods.each do |method_name|
121
+ old_method = :"old_#{method_name}"
122
+ new_method = :"synchronized_#{method_name}"
123
+
124
+ self.class.__send__(:alias_method, old_method, method_name)
125
+
126
+ self.class.send(:define_method, new_method) do |*args|
127
+ @lock.synchronize do
128
+ __send__(old_method, *args)
129
+ end
130
+ end
131
+
132
+ self.class.__send__(:alias_method, method_name, new_method)
133
+ end
134
+ end
111
135
  end
112
136
  end
@@ -211,6 +211,42 @@ module Overcommit
211
211
  Subprocess.spawn_detached(args)
212
212
  end
213
213
 
214
+ # Return the number of processors used by the OS for process scheduling.
215
+ #
216
+ # @see https://github.com/grosser/parallel/blob/v1.6.1/lib/parallel/processor_count.rb#L17-L51
217
+ def processor_count # rubocop:disable all
218
+ @processor_count ||=
219
+ begin
220
+ if Overcommit::OS.windows?
221
+ require 'win32ole'
222
+ result = WIN32OLE.connect('winmgmts://').ExecQuery(
223
+ 'select NumberOfLogicalProcessors from Win32_Processor')
224
+ result.to_enum.collect(&:NumberOfLogicalProcessors).reduce(:+)
225
+ elsif File.readable?('/proc/cpuinfo')
226
+ IO.read('/proc/cpuinfo').scan(/^processor/).size
227
+ elsif File.executable?('/usr/bin/hwprefs')
228
+ IO.popen('/usr/bin/hwprefs thread_count').read.to_i
229
+ elsif File.executable?('/usr/sbin/psrinfo')
230
+ IO.popen('/usr/sbin/psrinfo').read.scan(/^.*on-*line/).size
231
+ elsif File.executable?('/usr/sbin/ioscan')
232
+ IO.popen('/usr/sbin/ioscan -kC processor') do |out|
233
+ out.read.scan(/^.*processor/).size
234
+ end
235
+ elsif File.executable?('/usr/sbin/pmcycles')
236
+ IO.popen('/usr/sbin/pmcycles -m').read.count("\n")
237
+ elsif File.executable?('/usr/sbin/lsdev')
238
+ IO.popen('/usr/sbin/lsdev -Cc processor -S 1').read.count("\n")
239
+ elsif File.executable?('/usr/sbin/sysctl')
240
+ IO.popen('/usr/sbin/sysctl -n hw.ncpu').read.to_i
241
+ elsif File.executable?('/sbin/sysctl')
242
+ IO.popen('/sbin/sysctl -n hw.ncpu').read.to_i
243
+ else
244
+ # Unknown platform; assume 1 processor
245
+ 1
246
+ end
247
+ end
248
+ end
249
+
214
250
  # Calls a block of code with a modified set of environment variables,
215
251
  # restoring them once the code has executed.
216
252
  def with_environment(env)
@@ -1,4 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Defines the gem version.
2
4
  module Overcommit
3
- VERSION = '0.30.0'
5
+ VERSION = '0.32.0'.freeze
4
6
  end
@@ -30,7 +30,15 @@ require 'yaml'
30
30
  # rubocop:disable Style/RescueModifier
31
31
  if gemfile = YAML.load_file('.overcommit.yml')['gemfile'] rescue nil
32
32
  ENV['BUNDLE_GEMFILE'] = gemfile
33
- require 'bundler/setup'
33
+ require 'bundler'
34
+
35
+ begin
36
+ Bundler.setup
37
+ rescue Bundler::BundlerError => ex
38
+ puts "Problem loading '#{gemfile}': #{ex.message}"
39
+ puts "Try running:\nbundle install --gemfile=#{gemfile}" if ex.is_a?(Bundler::GemNotFound)
40
+ exit 78 # EX_CONFIG
41
+ end
34
42
  end
35
43
  # rubocop:enable Style/RescueModifier
36
44
 
@@ -30,7 +30,15 @@ require 'yaml'
30
30
  # rubocop:disable Style/RescueModifier
31
31
  if gemfile = YAML.load_file('.overcommit.yml')['gemfile'] rescue nil
32
32
  ENV['BUNDLE_GEMFILE'] = gemfile
33
- require 'bundler/setup'
33
+ require 'bundler'
34
+
35
+ begin
36
+ Bundler.setup
37
+ rescue Bundler::BundlerError => ex
38
+ puts "Problem loading '#{gemfile}': #{ex.message}"
39
+ puts "Try running:\nbundle install --gemfile=#{gemfile}" if ex.is_a?(Bundler::GemNotFound)
40
+ exit 78 # EX_CONFIG
41
+ end
34
42
  end
35
43
  # rubocop:enable Style/RescueModifier
36
44
 
@@ -30,7 +30,15 @@ require 'yaml'
30
30
  # rubocop:disable Style/RescueModifier
31
31
  if gemfile = YAML.load_file('.overcommit.yml')['gemfile'] rescue nil
32
32
  ENV['BUNDLE_GEMFILE'] = gemfile
33
- require 'bundler/setup'
33
+ require 'bundler'
34
+
35
+ begin
36
+ Bundler.setup
37
+ rescue Bundler::BundlerError => ex
38
+ puts "Problem loading '#{gemfile}': #{ex.message}"
39
+ puts "Try running:\nbundle install --gemfile=#{gemfile}" if ex.is_a?(Bundler::GemNotFound)
40
+ exit 78 # EX_CONFIG
41
+ end
34
42
  end
35
43
  # rubocop:enable Style/RescueModifier
36
44
 
@@ -30,7 +30,15 @@ require 'yaml'
30
30
  # rubocop:disable Style/RescueModifier
31
31
  if gemfile = YAML.load_file('.overcommit.yml')['gemfile'] rescue nil
32
32
  ENV['BUNDLE_GEMFILE'] = gemfile
33
- require 'bundler/setup'
33
+ require 'bundler'
34
+
35
+ begin
36
+ Bundler.setup
37
+ rescue Bundler::BundlerError => ex
38
+ puts "Problem loading '#{gemfile}': #{ex.message}"
39
+ puts "Try running:\nbundle install --gemfile=#{gemfile}" if ex.is_a?(Bundler::GemNotFound)
40
+ exit 78 # EX_CONFIG
41
+ end
34
42
  end
35
43
  # rubocop:enable Style/RescueModifier
36
44
 
@@ -30,7 +30,15 @@ require 'yaml'
30
30
  # rubocop:disable Style/RescueModifier
31
31
  if gemfile = YAML.load_file('.overcommit.yml')['gemfile'] rescue nil
32
32
  ENV['BUNDLE_GEMFILE'] = gemfile
33
- require 'bundler/setup'
33
+ require 'bundler'
34
+
35
+ begin
36
+ Bundler.setup
37
+ rescue Bundler::BundlerError => ex
38
+ puts "Problem loading '#{gemfile}': #{ex.message}"
39
+ puts "Try running:\nbundle install --gemfile=#{gemfile}" if ex.is_a?(Bundler::GemNotFound)
40
+ exit 78 # EX_CONFIG
41
+ end
34
42
  end
35
43
  # rubocop:enable Style/RescueModifier
36
44
 
@@ -30,7 +30,15 @@ require 'yaml'
30
30
  # rubocop:disable Style/RescueModifier
31
31
  if gemfile = YAML.load_file('.overcommit.yml')['gemfile'] rescue nil
32
32
  ENV['BUNDLE_GEMFILE'] = gemfile
33
- require 'bundler/setup'
33
+ require 'bundler'
34
+
35
+ begin
36
+ Bundler.setup
37
+ rescue Bundler::BundlerError => ex
38
+ puts "Problem loading '#{gemfile}': #{ex.message}"
39
+ puts "Try running:\nbundle install --gemfile=#{gemfile}" if ex.is_a?(Bundler::GemNotFound)
40
+ exit 78 # EX_CONFIG
41
+ end
34
42
  end
35
43
  # rubocop:enable Style/RescueModifier
36
44
 
@@ -30,7 +30,15 @@ require 'yaml'
30
30
  # rubocop:disable Style/RescueModifier
31
31
  if gemfile = YAML.load_file('.overcommit.yml')['gemfile'] rescue nil
32
32
  ENV['BUNDLE_GEMFILE'] = gemfile
33
- require 'bundler/setup'
33
+ require 'bundler'
34
+
35
+ begin
36
+ Bundler.setup
37
+ rescue Bundler::BundlerError => ex
38
+ puts "Problem loading '#{gemfile}': #{ex.message}"
39
+ puts "Try running:\nbundle install --gemfile=#{gemfile}" if ex.is_a?(Bundler::GemNotFound)
40
+ exit 78 # EX_CONFIG
41
+ end
34
42
  end
35
43
  # rubocop:enable Style/RescueModifier
36
44
 
@@ -30,7 +30,15 @@ require 'yaml'
30
30
  # rubocop:disable Style/RescueModifier
31
31
  if gemfile = YAML.load_file('.overcommit.yml')['gemfile'] rescue nil
32
32
  ENV['BUNDLE_GEMFILE'] = gemfile
33
- require 'bundler/setup'
33
+ require 'bundler'
34
+
35
+ begin
36
+ Bundler.setup
37
+ rescue Bundler::BundlerError => ex
38
+ puts "Problem loading '#{gemfile}': #{ex.message}"
39
+ puts "Try running:\nbundle install --gemfile=#{gemfile}" if ex.is_a?(Bundler::GemNotFound)
40
+ exit 78 # EX_CONFIG
41
+ end
34
42
  end
35
43
  # rubocop:enable Style/RescueModifier
36
44
 
@@ -30,7 +30,15 @@ require 'yaml'
30
30
  # rubocop:disable Style/RescueModifier
31
31
  if gemfile = YAML.load_file('.overcommit.yml')['gemfile'] rescue nil
32
32
  ENV['BUNDLE_GEMFILE'] = gemfile
33
- require 'bundler/setup'
33
+ require 'bundler'
34
+
35
+ begin
36
+ Bundler.setup
37
+ rescue Bundler::BundlerError => ex
38
+ puts "Problem loading '#{gemfile}': #{ex.message}"
39
+ puts "Try running:\nbundle install --gemfile=#{gemfile}" if ex.is_a?(Bundler::GemNotFound)
40
+ exit 78 # EX_CONFIG
41
+ end
34
42
  end
35
43
  # rubocop:enable Style/RescueModifier
36
44
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: overcommit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.30.0
4
+ version: 0.32.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brigade Engineering
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-12-24 00:00:00.000000000 Z
12
+ date: 2016-02-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: childprocess
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 0.5.6
20
+ version: 0.5.8
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 0.5.6
27
+ version: 0.5.8
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: iniparse
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -39,6 +39,20 @@ dependencies:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
41
  version: '1.4'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rake
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '10.4'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '10.4'
42
56
  - !ruby/object:Gem::Dependency
43
57
  name: rspec
44
58
  requirement: !ruby/object:Gem::Requirement
@@ -96,6 +110,7 @@ files:
96
110
  - lib/overcommit/hook/commit_msg/empty_message.rb
97
111
  - lib/overcommit/hook/commit_msg/gerrit_change_id.rb
98
112
  - lib/overcommit/hook/commit_msg/hard_tabs.rb
113
+ - lib/overcommit/hook/commit_msg/message_format.rb
99
114
  - lib/overcommit/hook/commit_msg/russian_novel.rb
100
115
  - lib/overcommit/hook/commit_msg/single_line_subject.rb
101
116
  - lib/overcommit/hook/commit_msg/spell_check.rb
@@ -140,6 +155,7 @@ files:
140
155
  - lib/overcommit/hook/pre_commit/dogma.rb
141
156
  - lib/overcommit/hook/pre_commit/es_lint.rb
142
157
  - lib/overcommit/hook/pre_commit/execute_permissions.rb
158
+ - lib/overcommit/hook/pre_commit/forbidden_branches.rb
143
159
  - lib/overcommit/hook/pre_commit/go_lint.rb
144
160
  - lib/overcommit/hook/pre_commit/go_vet.rb
145
161
  - lib/overcommit/hook/pre_commit/haml_lint.rb
@@ -155,6 +171,7 @@ files:
155
171
  - lib/overcommit/hook/pre_commit/jsl.rb
156
172
  - lib/overcommit/hook/pre_commit/json_syntax.rb
157
173
  - lib/overcommit/hook/pre_commit/local_paths_in_gemfile.rb
174
+ - lib/overcommit/hook/pre_commit/mdl.rb
158
175
  - lib/overcommit/hook/pre_commit/merge_conflicts.rb
159
176
  - lib/overcommit/hook/pre_commit/nginx_test.rb
160
177
  - lib/overcommit/hook/pre_commit/pep257.rb