overcommit 0.21.0 → 0.22.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.
- checksums.yaml +4 -4
- data/config/default.yml +21 -0
- data/lib/overcommit/hook/base.rb +36 -4
- data/lib/overcommit/hook/pre_commit/berksfile_check.rb +1 -1
- data/lib/overcommit/hook/pre_commit/brakeman.rb +1 -2
- data/lib/overcommit/hook/pre_commit/bundle_check.rb +2 -2
- data/lib/overcommit/hook/pre_commit/chamber_security.rb +1 -1
- data/lib/overcommit/hook/pre_commit/coffee_lint.rb +1 -1
- data/lib/overcommit/hook/pre_commit/css_lint.rb +1 -1
- data/lib/overcommit/hook/pre_commit/go_lint.rb +1 -1
- data/lib/overcommit/hook/pre_commit/haml_lint.rb +1 -1
- data/lib/overcommit/hook/pre_commit/hard_tabs.rb +1 -1
- data/lib/overcommit/hook/pre_commit/js_hint.rb +1 -1
- data/lib/overcommit/hook/pre_commit/jscs.rb +1 -1
- data/lib/overcommit/hook/pre_commit/jsx_hint.rb +1 -1
- data/lib/overcommit/hook/pre_commit/jsxcs.rb +1 -1
- data/lib/overcommit/hook/pre_commit/local_paths_in_gemfile.rb +1 -1
- data/lib/overcommit/hook/pre_commit/merge_conflicts.rb +1 -1
- data/lib/overcommit/hook/pre_commit/python_flake8.rb +1 -1
- data/lib/overcommit/hook/pre_commit/reek.rb +1 -1
- data/lib/overcommit/hook/pre_commit/rubocop.rb +1 -1
- data/lib/overcommit/hook/pre_commit/scss_lint.rb +1 -1
- data/lib/overcommit/hook/pre_commit/shell_check.rb +1 -1
- data/lib/overcommit/hook/pre_commit/trailing_whitespace.rb +1 -1
- data/lib/overcommit/hook/pre_commit/travis_lint.rb +1 -1
- data/lib/overcommit/utils.rb +9 -3
- data/lib/overcommit/version.rb +1 -1
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be12e52142407d34b856e8cf7c3b9e1743f9318b
|
4
|
+
data.tar.gz: cbbf986c4d3e2a45d26b281e9716de2ef15cd2c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ccfb37216d910e8c14b7d935c42a74b2ab372016bfe2b3e8eee4f63195028db62d34dbedec808d9b704d49f75991951eeabcdc3a857bbddccd8ebd55c4f00ee
|
7
|
+
data.tar.gz: 2fe6b8c2563e6f709e7d844f4055386fd8a60f4239e82dedf9792b8efeb59d46ecf761c4f2c28998d1628cab1452c35cb125226090c29e35359776ebf83bbfe0
|
data/config/default.yml
CHANGED
@@ -52,6 +52,7 @@ PreCommit:
|
|
52
52
|
BerksfileCheck:
|
53
53
|
description: 'Checking Berksfile lock'
|
54
54
|
required_executable: 'berks'
|
55
|
+
flags: ['list', '--quiet']
|
55
56
|
install_command: 'gem install berks'
|
56
57
|
include:
|
57
58
|
- 'Berksfile'
|
@@ -61,6 +62,7 @@ PreCommit:
|
|
61
62
|
enabled: false
|
62
63
|
description: 'Checking for security vulnerabilities'
|
63
64
|
required_executable: 'brakeman'
|
65
|
+
flags: ['--exit-on-warn', '--quiet', '--summary', '--only-files']
|
64
66
|
install_command: 'gem install brakeman'
|
65
67
|
include:
|
66
68
|
- '**/*.rb'
|
@@ -72,6 +74,7 @@ PreCommit:
|
|
72
74
|
BundleCheck:
|
73
75
|
description: 'Checking Gemfile dependencies'
|
74
76
|
required_executable: 'bundle'
|
77
|
+
flags: ['check']
|
75
78
|
install_command: 'gem install bundler'
|
76
79
|
include:
|
77
80
|
- 'Gemfile'
|
@@ -82,6 +85,7 @@ PreCommit:
|
|
82
85
|
enabled: false
|
83
86
|
description: 'Checking that settings have been secured with Chamber'
|
84
87
|
required_executable: 'chamber'
|
88
|
+
flags: ['secure', '--files']
|
85
89
|
install_command: 'gem install chamber'
|
86
90
|
include:
|
87
91
|
- 'config/settings.yml'
|
@@ -90,12 +94,14 @@ PreCommit:
|
|
90
94
|
CoffeeLint:
|
91
95
|
description: 'Analyzing with coffeelint'
|
92
96
|
required_executable: 'coffeelint'
|
97
|
+
flags: ['--quiet']
|
93
98
|
install_command: 'npm install -g coffeelint'
|
94
99
|
include: '**/*.coffee'
|
95
100
|
|
96
101
|
CssLint:
|
97
102
|
description: 'Analyzing with csslint'
|
98
103
|
required_executable: 'csslint'
|
104
|
+
flags: ['--quiet', '--format=compact']
|
99
105
|
install_command: 'npm install -g csslint'
|
100
106
|
include: '**/*.css'
|
101
107
|
|
@@ -114,6 +120,8 @@ PreCommit:
|
|
114
120
|
HardTabs:
|
115
121
|
description: 'Checking for hard tabs'
|
116
122
|
quiet: true
|
123
|
+
required_executable: 'grep'
|
124
|
+
flags: ['-IHn', "\t"]
|
117
125
|
exclude:
|
118
126
|
- '**/*.go'
|
119
127
|
- '**/Makefile'
|
@@ -130,12 +138,14 @@ PreCommit:
|
|
130
138
|
Jscs:
|
131
139
|
description: 'Analyzing with JSCS'
|
132
140
|
required_executable: 'jscs'
|
141
|
+
flags: ['--reporter=inline', '--verbose']
|
133
142
|
install_command: 'npm install -g jscs'
|
134
143
|
include: '**/*.js'
|
135
144
|
|
136
145
|
Jsxcs:
|
137
146
|
description: 'Analyzing with JSXCS'
|
138
147
|
required_executable: 'jsxcs'
|
148
|
+
flags: ['--reporter=inline']
|
139
149
|
install_command: 'npm install -g jsxcs'
|
140
150
|
include: '**/*.jsx'
|
141
151
|
|
@@ -157,11 +167,15 @@ PreCommit:
|
|
157
167
|
|
158
168
|
LocalPathsInGemfile:
|
159
169
|
description: 'Checking for local paths in Gemfile'
|
170
|
+
required_executable: 'grep'
|
171
|
+
flags: ['-IHnE', '(\bpath:)|(:path\s*=>)']
|
160
172
|
include: '**/Gemfile'
|
161
173
|
|
162
174
|
MergeConflicts:
|
163
175
|
description: 'Checking for merge conflicts'
|
164
176
|
quiet: true
|
177
|
+
required_executable: 'grep'
|
178
|
+
flags: ['-IHn', '^<<<<<<<\s']
|
165
179
|
|
166
180
|
PryBinding:
|
167
181
|
description: 'Checking for instances of binding.pry'
|
@@ -184,8 +198,10 @@ PreCommit:
|
|
184
198
|
- 'db/structure.sql'
|
185
199
|
|
186
200
|
Reek:
|
201
|
+
enabled: false
|
187
202
|
description: 'Analyzing with Reek'
|
188
203
|
required_executable: 'reek'
|
204
|
+
flags: ['--single-line', '--no-color']
|
189
205
|
install_command: 'gem install reek'
|
190
206
|
include:
|
191
207
|
- '**/*.gemspec'
|
@@ -197,6 +213,7 @@ PreCommit:
|
|
197
213
|
Rubocop:
|
198
214
|
description: 'Analyzing with Rubocop'
|
199
215
|
required_executable: 'rubocop'
|
216
|
+
flags: ['--format=emacs', '--force-exclusion']
|
200
217
|
install_command: 'gem install rubocop'
|
201
218
|
include:
|
202
219
|
- '**/*.gemspec'
|
@@ -214,16 +231,20 @@ PreCommit:
|
|
214
231
|
ShellCheck:
|
215
232
|
description: 'Analyzing with ShellCheck'
|
216
233
|
required_executable: 'shellcheck'
|
234
|
+
flags: ['--format=gcc']
|
217
235
|
include: '**/*.sh'
|
218
236
|
|
219
237
|
TrailingWhitespace:
|
220
238
|
description: 'Checking for trailing whitespace'
|
239
|
+
required_executable: 'grep'
|
240
|
+
flags: ['-IHn', '\s$']
|
221
241
|
exclude:
|
222
242
|
- '**/db/structure.sql'
|
223
243
|
|
224
244
|
TravisLint:
|
225
245
|
description: 'Checking Travis CI configuration'
|
226
246
|
required_executable: 'travis'
|
247
|
+
flags: ['lint']
|
227
248
|
install_command: 'gem install travis'
|
228
249
|
include: '.travis.yml'
|
229
250
|
|
data/lib/overcommit/hook/base.rb
CHANGED
@@ -14,7 +14,7 @@ module Overcommit::Hook
|
|
14
14
|
MESSAGE_TYPES = [:error, :warning]
|
15
15
|
|
16
16
|
# Functionality common to all hooks.
|
17
|
-
class Base
|
17
|
+
class Base # rubocop:disable Metrics/ClassLength
|
18
18
|
extend Forwardable
|
19
19
|
|
20
20
|
def_delegators :@context, :modified_files
|
@@ -111,10 +111,42 @@ module Overcommit::Hook
|
|
111
111
|
Overcommit::Utils.execute(cmd)
|
112
112
|
end
|
113
113
|
|
114
|
-
def
|
114
|
+
def required_executable
|
115
115
|
@config['required_executable']
|
116
116
|
end
|
117
117
|
|
118
|
+
# Return command to execute for this hook.
|
119
|
+
#
|
120
|
+
# This is intended to be configurable so hooks can prefix their commands
|
121
|
+
# with `bundle exec` or similar. It will appends the command line flags
|
122
|
+
# specified by the `flags` option after.
|
123
|
+
#
|
124
|
+
# Note that any files intended to be passed must be handled by the hook
|
125
|
+
# itself.
|
126
|
+
#
|
127
|
+
# @return [Array<String>]
|
128
|
+
def command
|
129
|
+
Array(@config['command'] || required_executable) + flags
|
130
|
+
end
|
131
|
+
|
132
|
+
# Return command line flags to be passed to the command.
|
133
|
+
#
|
134
|
+
# This excludes the list of files, as that must be handled by the hook
|
135
|
+
# itself.
|
136
|
+
#
|
137
|
+
# The intention here is to provide flexibility for when a tool
|
138
|
+
# removes/renames its flags. Rather than wait for Overcommit to update the
|
139
|
+
# flags it uses, you can update your configuration to use the new flags
|
140
|
+
# right away without being blocked.
|
141
|
+
#
|
142
|
+
# Also note that any flags containing dynamic content must be passed in the
|
143
|
+
# hook's {#run} method.
|
144
|
+
#
|
145
|
+
# @return [Array<String>]
|
146
|
+
def flags
|
147
|
+
Array(@config['flags'])
|
148
|
+
end
|
149
|
+
|
118
150
|
# Gets a list of staged files that apply to this hook based on its
|
119
151
|
# configured `include` and `exclude` lists.
|
120
152
|
def applicable_files
|
@@ -146,9 +178,9 @@ module Overcommit::Hook
|
|
146
178
|
# If the hook defines a required executable, check if it's in the path and
|
147
179
|
# display the install command if one exists.
|
148
180
|
def check_for_executable
|
149
|
-
return unless
|
181
|
+
return unless required_executable && !in_path?(required_executable)
|
150
182
|
|
151
|
-
output = "'#{
|
183
|
+
output = "'#{required_executable}' is not installed (or is not in your PATH)"
|
152
184
|
|
153
185
|
if install_command = @config['install_command']
|
154
186
|
output += "\nInstall it by running: #{install_command}"
|
@@ -9,7 +9,7 @@ module Overcommit::Hook::PreCommit
|
|
9
9
|
ignored_files = execute(%w[git ls-files -o -i --exclude-standard]).stdout.split("\n")
|
10
10
|
return :pass if ignored_files.include?(LOCK_FILE)
|
11
11
|
|
12
|
-
result = execute(
|
12
|
+
result = execute(command)
|
13
13
|
unless result.success?
|
14
14
|
return :fail, result.stderr
|
15
15
|
end
|
@@ -2,8 +2,7 @@ module Overcommit::Hook::PreCommit
|
|
2
2
|
# Runs `brakeman` against any modified Ruby/Rails files.
|
3
3
|
class Brakeman < Base
|
4
4
|
def run
|
5
|
-
result = execute(
|
6
|
-
applicable_files.join(','))
|
5
|
+
result = execute(command + [applicable_files.join(',')])
|
7
6
|
return :pass if result.success?
|
8
7
|
|
9
8
|
[:fail, result.stdout]
|
@@ -9,14 +9,14 @@ module Overcommit::Hook::PreCommit
|
|
9
9
|
ignored_files = execute(%w[git ls-files -o -i --exclude-standard]).stdout.split("\n")
|
10
10
|
return :pass if ignored_files.include?(LOCK_FILE)
|
11
11
|
|
12
|
-
result = execute(
|
12
|
+
result = execute(command)
|
13
13
|
unless result.success?
|
14
14
|
return :fail, result.stdout
|
15
15
|
end
|
16
16
|
|
17
17
|
result = execute(%w[git diff --quiet --] + [LOCK_FILE])
|
18
18
|
unless result.success?
|
19
|
-
return :fail, "#{LOCK_FILE} is not up-to-date -- run `#{
|
19
|
+
return :fail, "#{LOCK_FILE} is not up-to-date -- run `#{command.join(' ')} check`"
|
20
20
|
end
|
21
21
|
|
22
22
|
:pass
|
@@ -2,7 +2,7 @@ module Overcommit::Hook::PreCommit
|
|
2
2
|
# Runs `chamber secure` against any modified Chamber settings files
|
3
3
|
class ChamberSecurity < Base
|
4
4
|
def run
|
5
|
-
result = execute(
|
5
|
+
result = execute(command + applicable_files)
|
6
6
|
|
7
7
|
return :pass if result.stdout.empty?
|
8
8
|
[:fail, "These settings appear to need to be secured but were not: #{result.stdout}"]
|
@@ -2,7 +2,7 @@ module Overcommit::Hook::PreCommit
|
|
2
2
|
# Runs `coffeelint` against any modified CoffeeScript files.
|
3
3
|
class CoffeeLint < Base
|
4
4
|
def run
|
5
|
-
result = execute(
|
5
|
+
result = execute(command + applicable_files)
|
6
6
|
return :pass if result.success?
|
7
7
|
|
8
8
|
[:fail, result.stdout]
|
@@ -2,7 +2,7 @@ module Overcommit::Hook::PreCommit
|
|
2
2
|
# Runs `csslint` against any modified CSS files.
|
3
3
|
class CssLint < Base
|
4
4
|
def run
|
5
|
-
result = execute(
|
5
|
+
result = execute(command + applicable_files)
|
6
6
|
return :pass if result.stdout !~ /Error - (?!Unknown @ rule)/
|
7
7
|
|
8
8
|
[:fail, result.stdout]
|
@@ -2,7 +2,7 @@ module Overcommit::Hook::PreCommit
|
|
2
2
|
# Runs `golint` against any modified Golang files.
|
3
3
|
class GoLint < Base
|
4
4
|
def run
|
5
|
-
result = execute(
|
5
|
+
result = execute(command + applicable_files)
|
6
6
|
# Unfortunately the exit code is always 0
|
7
7
|
return :pass if result.stdout.empty?
|
8
8
|
|
@@ -3,7 +3,7 @@ module Overcommit::Hook::PreCommit
|
|
3
3
|
class HardTabs < Base
|
4
4
|
def run
|
5
5
|
# Catches hard tabs
|
6
|
-
result = execute(
|
6
|
+
result = execute(command + applicable_files)
|
7
7
|
unless result.stdout.empty?
|
8
8
|
return :fail, "Hard tabs detected:\n#{result.stdout}"
|
9
9
|
end
|
@@ -2,7 +2,7 @@ module Overcommit::Hook::PreCommit
|
|
2
2
|
# Runs `jshint` against any modified JavaScript files.
|
3
3
|
class JsHint < Base
|
4
4
|
def run
|
5
|
-
result = execute(
|
5
|
+
result = execute(command + applicable_files)
|
6
6
|
output = result.stdout
|
7
7
|
|
8
8
|
return :pass if output.empty?
|
@@ -2,7 +2,7 @@ module Overcommit::Hook::PreCommit
|
|
2
2
|
# Runs `jsxhint` against any modified JSX files.
|
3
3
|
class JsxHint < Base
|
4
4
|
def run
|
5
|
-
result = execute(
|
5
|
+
result = execute(command + applicable_files)
|
6
6
|
output = result.stdout
|
7
7
|
|
8
8
|
return :pass if output.empty?
|
@@ -3,7 +3,7 @@ module Overcommit::Hook::PreCommit
|
|
3
3
|
# against any modified JavaScript files.
|
4
4
|
class Jsxcs < Base
|
5
5
|
def run
|
6
|
-
result = execute(
|
6
|
+
result = execute(command + applicable_files)
|
7
7
|
return :pass if result.success?
|
8
8
|
|
9
9
|
if result.status == 1
|
@@ -2,7 +2,7 @@ module Overcommit::Hook::PreCommit
|
|
2
2
|
# Checks for local paths in files and issues a warning
|
3
3
|
class LocalPathsInGemfile < Base
|
4
4
|
def run
|
5
|
-
result = execute(
|
5
|
+
result = execute(command + applicable_files)
|
6
6
|
|
7
7
|
unless result.stdout.empty?
|
8
8
|
return :warn, "Avoid pointing to local paths in Gemfiles:\n#{result.stdout}"
|
@@ -2,7 +2,7 @@ module Overcommit::Hook::PreCommit
|
|
2
2
|
# Checks for unresolved merge conflicts
|
3
3
|
class MergeConflicts < Base
|
4
4
|
def run
|
5
|
-
result = execute(
|
5
|
+
result = execute(command + applicable_files)
|
6
6
|
|
7
7
|
unless result.stdout.empty?
|
8
8
|
return :fail, "Merge conflict markers detected:\n#{result.stdout}"
|
@@ -2,7 +2,7 @@ module Overcommit::Hook::PreCommit
|
|
2
2
|
# Runs `flake8` against any modified Python files.
|
3
3
|
class PythonFlake8 < Base
|
4
4
|
def run
|
5
|
-
result = execute(
|
5
|
+
result = execute(command + applicable_files)
|
6
6
|
return :pass if result.success?
|
7
7
|
|
8
8
|
[:fail, result.stdout]
|
@@ -2,7 +2,7 @@ module Overcommit::Hook::PreCommit
|
|
2
2
|
# Runs `reek` against any modified Ruby files.
|
3
3
|
class Reek < Base
|
4
4
|
def run
|
5
|
-
result = execute(
|
5
|
+
result = execute(command + applicable_files)
|
6
6
|
return :pass if result.success?
|
7
7
|
|
8
8
|
output = scrub_output(result.stdout + result.stderr)
|
@@ -2,7 +2,7 @@ module Overcommit::Hook::PreCommit
|
|
2
2
|
# Checks for trailing whitespace in files.
|
3
3
|
class TrailingWhitespace < Base
|
4
4
|
def run
|
5
|
-
result = execute(
|
5
|
+
result = execute(command + applicable_files)
|
6
6
|
unless result.stdout.empty?
|
7
7
|
return :fail, "Trailing whitespace detected:\n#{result.stdout}"
|
8
8
|
end
|
@@ -2,7 +2,7 @@ module Overcommit::Hook::PreCommit
|
|
2
2
|
# Runs `travis-lint` against any modified Travis CI files.
|
3
3
|
class TravisLint < Base
|
4
4
|
def run
|
5
|
-
result = execute(
|
5
|
+
result = execute(command + applicable_files)
|
6
6
|
return :pass if result.success?
|
7
7
|
|
8
8
|
[:fail, (result.stdout + result.stderr).strip]
|
data/lib/overcommit/utils.rb
CHANGED
@@ -83,10 +83,16 @@ module Overcommit
|
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
|
-
#
|
86
|
+
# @param cmd [String]
|
87
|
+
# @return [true,false] whether a command can be found given the current
|
88
|
+
# environment path.
|
87
89
|
def in_path?(cmd)
|
88
|
-
|
89
|
-
|
90
|
+
# ENV['PATH'] doesn't include the repo root, but that is a valid
|
91
|
+
# location for executables, so we want to add it to the list of places
|
92
|
+
# we are checking for the executable.
|
93
|
+
paths = [repo_root] + ENV['PATH'].split(File::PATH_SEPARATOR)
|
94
|
+
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
|
95
|
+
paths.each do |path|
|
90
96
|
exts.each do |ext|
|
91
97
|
exe = File.join(path, "#{cmd}#{ext}")
|
92
98
|
return true if File.executable?(exe)
|
data/lib/overcommit/version.rb
CHANGED
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.
|
4
|
+
version: 0.22.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Causes Engineering
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-02-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: childprocess
|
@@ -179,4 +179,3 @@ signing_key:
|
|
179
179
|
specification_version: 4
|
180
180
|
summary: Git hook manager
|
181
181
|
test_files: []
|
182
|
-
has_rdoc:
|