overcommit 0.23.0 → 0.24.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/bin/overcommit +1 -1
  3. data/config/default.yml +154 -18
  4. data/config/starter.yml +3 -3
  5. data/lib/overcommit.rb +2 -1
  6. data/lib/overcommit/cli.rb +11 -8
  7. data/lib/overcommit/configuration.rb +18 -4
  8. data/lib/overcommit/configuration_loader.rb +45 -28
  9. data/lib/overcommit/configuration_validator.rb +33 -1
  10. data/lib/overcommit/constants.rb +5 -3
  11. data/lib/overcommit/exceptions.rb +3 -0
  12. data/lib/overcommit/git_repo.rb +116 -0
  13. data/lib/overcommit/git_version.rb +15 -0
  14. data/lib/overcommit/hook/base.rb +42 -5
  15. data/lib/overcommit/hook/commit_msg/capitalized_subject.rb +13 -0
  16. data/lib/overcommit/hook/commit_msg/spell_check.rb +41 -0
  17. data/lib/overcommit/hook/post_checkout/submodule_status.rb +30 -0
  18. data/lib/overcommit/hook/post_commit/submodule_status.rb +30 -0
  19. data/lib/overcommit/hook/post_merge/submodule_status.rb +30 -0
  20. data/lib/overcommit/hook/post_rewrite/submodule_status.rb +30 -0
  21. data/lib/overcommit/hook/pre_commit/base.rb +2 -2
  22. data/lib/overcommit/hook/pre_commit/bundle_check.rb +1 -1
  23. data/lib/overcommit/hook/pre_commit/case_conflicts.rb +20 -0
  24. data/lib/overcommit/hook/pre_commit/coffee_lint.rb +29 -2
  25. data/lib/overcommit/hook/pre_commit/css_lint.rb +1 -8
  26. data/lib/overcommit/hook/pre_commit/go_lint.rb +8 -2
  27. data/lib/overcommit/hook/pre_commit/go_vet.rb +20 -0
  28. data/lib/overcommit/hook/pre_commit/html_tidy.rb +1 -10
  29. data/lib/overcommit/hook/pre_commit/image_optim.rb +11 -28
  30. data/lib/overcommit/hook/pre_commit/js_lint.rb +18 -0
  31. data/lib/overcommit/hook/pre_commit/jsl.rb +24 -0
  32. data/lib/overcommit/hook/pre_commit/json_syntax.rb +4 -7
  33. data/lib/overcommit/hook/pre_commit/rails_schema_up_to_date.rb +1 -1
  34. data/lib/overcommit/hook/pre_commit/ruby_lint.rb +19 -0
  35. data/lib/overcommit/hook/pre_commit/scss_lint.rb +8 -1
  36. data/lib/overcommit/hook/pre_commit/w3c_css.rb +4 -18
  37. data/lib/overcommit/hook/pre_commit/w3c_html.rb +4 -18
  38. data/lib/overcommit/hook/pre_commit/xml_syntax.rb +19 -0
  39. data/lib/overcommit/hook/pre_commit/yaml_syntax.rb +4 -8
  40. data/lib/overcommit/hook/pre_push/base.rb +10 -0
  41. data/lib/overcommit/hook/pre_push/protected_branches.rb +27 -0
  42. data/lib/overcommit/hook/pre_push/r_spec.rb +12 -0
  43. data/lib/overcommit/hook/pre_rebase/base.rb +11 -0
  44. data/lib/overcommit/hook_context.rb +2 -2
  45. data/lib/overcommit/hook_context/base.rb +5 -7
  46. data/lib/overcommit/hook_context/pre_commit.rb +66 -16
  47. data/lib/overcommit/hook_context/pre_push.rb +44 -0
  48. data/lib/overcommit/hook_context/pre_rebase.rb +36 -0
  49. data/lib/overcommit/hook_runner.rb +27 -7
  50. data/lib/overcommit/installer.rb +46 -7
  51. data/lib/overcommit/message_processor.rb +3 -0
  52. data/lib/overcommit/printer.rb +8 -12
  53. data/lib/overcommit/subprocess.rb +11 -0
  54. data/lib/overcommit/utils.rb +28 -6
  55. data/lib/overcommit/version.rb +1 -1
  56. data/template-dir/hooks/commit-msg +2 -2
  57. data/template-dir/hooks/overcommit-hook +2 -2
  58. data/template-dir/hooks/post-checkout +2 -2
  59. data/template-dir/hooks/post-commit +2 -2
  60. data/template-dir/hooks/post-merge +2 -2
  61. data/template-dir/hooks/post-rewrite +2 -2
  62. data/template-dir/hooks/pre-commit +2 -2
  63. data/template-dir/hooks/pre-push +81 -0
  64. data/template-dir/hooks/pre-rebase +81 -0
  65. metadata +33 -13
  66. data/lib/overcommit/hook/pre_commit/pry_binding.rb +0 -14
@@ -43,9 +43,9 @@ begin
43
43
  exec($0, *ARGV) # Execute the updated hook with all original arguments
44
44
  end
45
45
 
46
- config = Overcommit::ConfigurationLoader.load_repo_config
46
+ config = Overcommit::ConfigurationLoader.new(logger).load_repo_config
47
47
 
48
- context = Overcommit::HookContext.create(hook_type, config, ARGV)
48
+ context = Overcommit::HookContext.create(hook_type, config, ARGV, STDIN)
49
49
  config.apply_environment!(context, ENV)
50
50
 
51
51
  printer = Overcommit::Printer.new(logger, context)
@@ -43,9 +43,9 @@ begin
43
43
  exec($0, *ARGV) # Execute the updated hook with all original arguments
44
44
  end
45
45
 
46
- config = Overcommit::ConfigurationLoader.load_repo_config
46
+ config = Overcommit::ConfigurationLoader.new(logger).load_repo_config
47
47
 
48
- context = Overcommit::HookContext.create(hook_type, config, ARGV)
48
+ context = Overcommit::HookContext.create(hook_type, config, ARGV, STDIN)
49
49
  config.apply_environment!(context, ENV)
50
50
 
51
51
  printer = Overcommit::Printer.new(logger, context)
@@ -43,9 +43,9 @@ begin
43
43
  exec($0, *ARGV) # Execute the updated hook with all original arguments
44
44
  end
45
45
 
46
- config = Overcommit::ConfigurationLoader.load_repo_config
46
+ config = Overcommit::ConfigurationLoader.new(logger).load_repo_config
47
47
 
48
- context = Overcommit::HookContext.create(hook_type, config, ARGV)
48
+ context = Overcommit::HookContext.create(hook_type, config, ARGV, STDIN)
49
49
  config.apply_environment!(context, ENV)
50
50
 
51
51
  printer = Overcommit::Printer.new(logger, context)
@@ -43,9 +43,9 @@ begin
43
43
  exec($0, *ARGV) # Execute the updated hook with all original arguments
44
44
  end
45
45
 
46
- config = Overcommit::ConfigurationLoader.load_repo_config
46
+ config = Overcommit::ConfigurationLoader.new(logger).load_repo_config
47
47
 
48
- context = Overcommit::HookContext.create(hook_type, config, ARGV)
48
+ context = Overcommit::HookContext.create(hook_type, config, ARGV, STDIN)
49
49
  config.apply_environment!(context, ENV)
50
50
 
51
51
  printer = Overcommit::Printer.new(logger, context)
@@ -0,0 +1,81 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Entrypoint for Overcommit hook integration. Installing Overcommit will result
4
+ # in all of your git hooks being symlinked to this file, allowing the framework
5
+ # to manage your hooks for you.
6
+
7
+ # Prevent a Ruby stack trace from appearing when we interrupt the hook.
8
+ # Note that this will be overridden when Overcommit is loaded, since the
9
+ # InterruptHandler will redefine the trap at that time.
10
+ Signal.trap('INT') do
11
+ puts 'Hook run interrupted'
12
+ exit 130
13
+ end
14
+
15
+ # Allow hooks to be disabled via environment variable so git commands can be run
16
+ # in scripts without Overcommit running hooks
17
+ if ENV['OVERCOMMIT_DISABLE'].to_i != 0 || ENV['OVERCOMMIT_DISABLED'].to_i != 0
18
+ exit
19
+ end
20
+
21
+ hook_type = File.basename($0)
22
+ if hook_type == 'overcommit-hook'
23
+ puts "Don't run `overcommit-hook` directly; it is intended to be symlinked " \
24
+ "by each hook in a repository's .git/hooks directory."
25
+ exit 64 # EX_USAGE
26
+ end
27
+
28
+ begin
29
+ require 'overcommit'
30
+ rescue LoadError
31
+ puts 'This repository contains hooks installed by Overcommit, but the ' \
32
+ "overcommit gem is not installed.\n" \
33
+ 'Install it with `gem install overcommit`.'
34
+ exit
35
+ end
36
+
37
+ begin
38
+ logger = Overcommit::Logger.new(STDOUT)
39
+
40
+ # Ensure master hook is up-to-date
41
+ installer = Overcommit::Installer.new(logger)
42
+ if installer.run(Overcommit::Utils.repo_root, action: :update)
43
+ exec($0, *ARGV) # Execute the updated hook with all original arguments
44
+ end
45
+
46
+ config = Overcommit::ConfigurationLoader.new(logger).load_repo_config
47
+
48
+ context = Overcommit::HookContext.create(hook_type, config, ARGV, STDIN)
49
+ config.apply_environment!(context, ENV)
50
+
51
+ printer = Overcommit::Printer.new(logger, context)
52
+ runner = Overcommit::HookRunner.new(config, logger, context, printer)
53
+
54
+ status = runner.run
55
+
56
+ exit(status ? 0 : 65) # 65 = EX_DATAERR
57
+ rescue Overcommit::Exceptions::ConfigurationError => error
58
+ puts error
59
+ exit 78 # EX_CONFIG
60
+ rescue Overcommit::Exceptions::HookContextLoadError => error
61
+ puts error
62
+ puts 'Are you running an old version of Overcommit?'
63
+ exit 69 # EX_UNAVAILABLE
64
+ rescue Overcommit::Exceptions::HookSetupFailed,
65
+ Overcommit::Exceptions::HookCleanupFailed => error
66
+ puts error.message
67
+ exit 74 # EX_IOERR
68
+ rescue Overcommit::Exceptions::HookCancelled
69
+ puts 'You cancelled the hook run'
70
+ exit 130 # Ctrl-C cancel
71
+ rescue Overcommit::Exceptions::InvalidGitRepo => error
72
+ puts error
73
+ exit 64 # EX_USAGE
74
+ rescue Overcommit::Exceptions::InvalidHookSignature
75
+ exit 1
76
+ rescue => error
77
+ puts error.message
78
+ puts error.backtrace
79
+ puts "Report this bug at #{Overcommit::BUG_REPORT_URL}"
80
+ exit 70 # EX_SOFTWARE
81
+ end
@@ -0,0 +1,81 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Entrypoint for Overcommit hook integration. Installing Overcommit will result
4
+ # in all of your git hooks being symlinked to this file, allowing the framework
5
+ # to manage your hooks for you.
6
+
7
+ # Prevent a Ruby stack trace from appearing when we interrupt the hook.
8
+ # Note that this will be overridden when Overcommit is loaded, since the
9
+ # InterruptHandler will redefine the trap at that time.
10
+ Signal.trap('INT') do
11
+ puts 'Hook run interrupted'
12
+ exit 130
13
+ end
14
+
15
+ # Allow hooks to be disabled via environment variable so git commands can be run
16
+ # in scripts without Overcommit running hooks
17
+ if ENV['OVERCOMMIT_DISABLE'].to_i != 0 || ENV['OVERCOMMIT_DISABLED'].to_i != 0
18
+ exit
19
+ end
20
+
21
+ hook_type = File.basename($0)
22
+ if hook_type == 'overcommit-hook'
23
+ puts "Don't run `overcommit-hook` directly; it is intended to be symlinked " \
24
+ "by each hook in a repository's .git/hooks directory."
25
+ exit 64 # EX_USAGE
26
+ end
27
+
28
+ begin
29
+ require 'overcommit'
30
+ rescue LoadError
31
+ puts 'This repository contains hooks installed by Overcommit, but the ' \
32
+ "overcommit gem is not installed.\n" \
33
+ 'Install it with `gem install overcommit`.'
34
+ exit
35
+ end
36
+
37
+ begin
38
+ logger = Overcommit::Logger.new(STDOUT)
39
+
40
+ # Ensure master hook is up-to-date
41
+ installer = Overcommit::Installer.new(logger)
42
+ if installer.run(Overcommit::Utils.repo_root, action: :update)
43
+ exec($0, *ARGV) # Execute the updated hook with all original arguments
44
+ end
45
+
46
+ config = Overcommit::ConfigurationLoader.new(logger).load_repo_config
47
+
48
+ context = Overcommit::HookContext.create(hook_type, config, ARGV, STDIN)
49
+ config.apply_environment!(context, ENV)
50
+
51
+ printer = Overcommit::Printer.new(logger, context)
52
+ runner = Overcommit::HookRunner.new(config, logger, context, printer)
53
+
54
+ status = runner.run
55
+
56
+ exit(status ? 0 : 65) # 65 = EX_DATAERR
57
+ rescue Overcommit::Exceptions::ConfigurationError => error
58
+ puts error
59
+ exit 78 # EX_CONFIG
60
+ rescue Overcommit::Exceptions::HookContextLoadError => error
61
+ puts error
62
+ puts 'Are you running an old version of Overcommit?'
63
+ exit 69 # EX_UNAVAILABLE
64
+ rescue Overcommit::Exceptions::HookSetupFailed,
65
+ Overcommit::Exceptions::HookCleanupFailed => error
66
+ puts error.message
67
+ exit 74 # EX_IOERR
68
+ rescue Overcommit::Exceptions::HookCancelled
69
+ puts 'You cancelled the hook run'
70
+ exit 130 # Ctrl-C cancel
71
+ rescue Overcommit::Exceptions::InvalidGitRepo => error
72
+ puts error
73
+ exit 64 # EX_USAGE
74
+ rescue Overcommit::Exceptions::InvalidHookSignature
75
+ exit 1
76
+ rescue => error
77
+ puts error.message
78
+ puts error.backtrace
79
+ puts "Report this bug at #{Overcommit::BUG_REPORT_URL}"
80
+ exit 70 # EX_SOFTWARE
81
+ end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: overcommit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.23.0
4
+ version: 0.24.0
5
5
  platform: ruby
6
6
  authors:
7
- - Causes Engineering
7
+ - Brigade Engineering
8
8
  - Shane da Silva
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-02-27 00:00:00.000000000 Z
12
+ date: 2015-04-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: childprocess
@@ -17,28 +17,28 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 0.5.0
20
+ version: 0.5.6
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.0
27
+ version: 0.5.6
28
28
  - !ruby/object:Gem::Dependency
29
- name: image_optim
29
+ name: iniparse
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: 0.20.0
35
- type: :development
34
+ version: '1.4'
35
+ type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: 0.20.0
41
+ version: '1.4'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rspec
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -83,8 +83,8 @@ dependencies:
83
83
  version: '1.2'
84
84
  description: Utility to install, configure, and extend Git hooks
85
85
  email:
86
- - eng@causes.com
87
- - shane@causes.com
86
+ - eng@brigade.com
87
+ - shane.dasilva@brigade.com
88
88
  executables:
89
89
  - overcommit
90
90
  extensions: []
@@ -101,23 +101,30 @@ files:
101
101
  - lib/overcommit/constants.rb
102
102
  - lib/overcommit/exceptions.rb
103
103
  - lib/overcommit/git_repo.rb
104
+ - lib/overcommit/git_version.rb
104
105
  - lib/overcommit/hook/base.rb
105
106
  - lib/overcommit/hook/commit_msg/base.rb
107
+ - lib/overcommit/hook/commit_msg/capitalized_subject.rb
106
108
  - lib/overcommit/hook/commit_msg/gerrit_change_id.rb
107
109
  - lib/overcommit/hook/commit_msg/hard_tabs.rb
108
110
  - lib/overcommit/hook/commit_msg/russian_novel.rb
109
111
  - lib/overcommit/hook/commit_msg/single_line_subject.rb
112
+ - lib/overcommit/hook/commit_msg/spell_check.rb
110
113
  - lib/overcommit/hook/commit_msg/text_width.rb
111
114
  - lib/overcommit/hook/commit_msg/trailing_period.rb
112
115
  - lib/overcommit/hook/post_checkout/base.rb
113
116
  - lib/overcommit/hook/post_checkout/index_tags.rb
117
+ - lib/overcommit/hook/post_checkout/submodule_status.rb
114
118
  - lib/overcommit/hook/post_commit/base.rb
115
119
  - lib/overcommit/hook/post_commit/git_guilt.rb
116
120
  - lib/overcommit/hook/post_commit/index_tags.rb
121
+ - lib/overcommit/hook/post_commit/submodule_status.rb
117
122
  - lib/overcommit/hook/post_merge/base.rb
118
123
  - lib/overcommit/hook/post_merge/index_tags.rb
124
+ - lib/overcommit/hook/post_merge/submodule_status.rb
119
125
  - lib/overcommit/hook/post_rewrite/base.rb
120
126
  - lib/overcommit/hook/post_rewrite/index_tags.rb
127
+ - lib/overcommit/hook/post_rewrite/submodule_status.rb
121
128
  - lib/overcommit/hook/pre_commit/author_email.rb
122
129
  - lib/overcommit/hook/pre_commit/author_name.rb
123
130
  - lib/overcommit/hook/pre_commit/base.rb
@@ -125,30 +132,34 @@ files:
125
132
  - lib/overcommit/hook/pre_commit/brakeman.rb
126
133
  - lib/overcommit/hook/pre_commit/broken_symlinks.rb
127
134
  - lib/overcommit/hook/pre_commit/bundle_check.rb
135
+ - lib/overcommit/hook/pre_commit/case_conflicts.rb
128
136
  - lib/overcommit/hook/pre_commit/chamber_security.rb
129
137
  - lib/overcommit/hook/pre_commit/coffee_lint.rb
130
138
  - lib/overcommit/hook/pre_commit/css_lint.rb
131
139
  - lib/overcommit/hook/pre_commit/es_lint.rb
132
140
  - lib/overcommit/hook/pre_commit/go_lint.rb
141
+ - lib/overcommit/hook/pre_commit/go_vet.rb
133
142
  - lib/overcommit/hook/pre_commit/haml_lint.rb
134
143
  - lib/overcommit/hook/pre_commit/hard_tabs.rb
135
144
  - lib/overcommit/hook/pre_commit/html_tidy.rb
136
145
  - lib/overcommit/hook/pre_commit/image_optim.rb
137
146
  - lib/overcommit/hook/pre_commit/java_checkstyle.rb
138
147
  - lib/overcommit/hook/pre_commit/js_hint.rb
148
+ - lib/overcommit/hook/pre_commit/js_lint.rb
139
149
  - lib/overcommit/hook/pre_commit/jscs.rb
150
+ - lib/overcommit/hook/pre_commit/jsl.rb
140
151
  - lib/overcommit/hook/pre_commit/json_syntax.rb
141
152
  - lib/overcommit/hook/pre_commit/local_paths_in_gemfile.rb
142
153
  - lib/overcommit/hook/pre_commit/merge_conflicts.rb
143
154
  - lib/overcommit/hook/pre_commit/pep257.rb
144
155
  - lib/overcommit/hook/pre_commit/pep8.rb
145
- - lib/overcommit/hook/pre_commit/pry_binding.rb
146
156
  - lib/overcommit/hook/pre_commit/pyflakes.rb
147
157
  - lib/overcommit/hook/pre_commit/pylint.rb
148
158
  - lib/overcommit/hook/pre_commit/python_flake8.rb
149
159
  - lib/overcommit/hook/pre_commit/rails_schema_up_to_date.rb
150
160
  - lib/overcommit/hook/pre_commit/reek.rb
151
161
  - lib/overcommit/hook/pre_commit/rubocop.rb
162
+ - lib/overcommit/hook/pre_commit/ruby_lint.rb
152
163
  - lib/overcommit/hook/pre_commit/scalastyle.rb
153
164
  - lib/overcommit/hook/pre_commit/scss_lint.rb
154
165
  - lib/overcommit/hook/pre_commit/semi_standard.rb
@@ -159,7 +170,12 @@ files:
159
170
  - lib/overcommit/hook/pre_commit/w3c_css.rb
160
171
  - lib/overcommit/hook/pre_commit/w3c_html.rb
161
172
  - lib/overcommit/hook/pre_commit/xml_lint.rb
173
+ - lib/overcommit/hook/pre_commit/xml_syntax.rb
162
174
  - lib/overcommit/hook/pre_commit/yaml_syntax.rb
175
+ - lib/overcommit/hook/pre_push/base.rb
176
+ - lib/overcommit/hook/pre_push/protected_branches.rb
177
+ - lib/overcommit/hook/pre_push/r_spec.rb
178
+ - lib/overcommit/hook/pre_rebase/base.rb
163
179
  - lib/overcommit/hook_context.rb
164
180
  - lib/overcommit/hook_context/base.rb
165
181
  - lib/overcommit/hook_context/commit_msg.rb
@@ -168,6 +184,8 @@ files:
168
184
  - lib/overcommit/hook_context/post_merge.rb
169
185
  - lib/overcommit/hook_context/post_rewrite.rb
170
186
  - lib/overcommit/hook_context/pre_commit.rb
187
+ - lib/overcommit/hook_context/pre_push.rb
188
+ - lib/overcommit/hook_context/pre_rebase.rb
171
189
  - lib/overcommit/hook_context/run_all.rb
172
190
  - lib/overcommit/hook_loader/base.rb
173
191
  - lib/overcommit/hook_loader/built_in_hook_loader.rb
@@ -191,7 +209,9 @@ files:
191
209
  - template-dir/hooks/post-merge
192
210
  - template-dir/hooks/post-rewrite
193
211
  - template-dir/hooks/pre-commit
194
- homepage: https://github.com/causes/overcommit
212
+ - template-dir/hooks/pre-push
213
+ - template-dir/hooks/pre-rebase
214
+ homepage: https://github.com/brigade/overcommit
195
215
  licenses:
196
216
  - MIT
197
217
  metadata: {}
@@ -1,14 +0,0 @@
1
- module Overcommit::Hook::PreCommit
2
- # Adds a check to make sure no `binding.pry`'s have been left in the code
3
- class PryBinding < Base
4
- def run
5
- result = execute(%w[grep -IHnE ^\s*binding\.pry] + applicable_files)
6
-
7
- unless result.stdout.empty?
8
- return :fail, "Found a `binding.pry` call left in:\n#{result.stdout}"
9
- end
10
-
11
- :pass
12
- end
13
- end
14
- end