overcommit 0.39.0 → 0.40.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/bin/overcommit +6 -2
- data/config/default.yml +49 -2
- data/lib/overcommit/configuration.rb +3 -3
- data/lib/overcommit/git_config.rb +8 -0
- data/lib/overcommit/hook/pre_commit/hadolint.rb +25 -0
- data/lib/overcommit/hook/pre_commit/license_finder.rb +12 -0
- data/lib/overcommit/hook/pre_commit/line_endings.rb +28 -9
- data/lib/overcommit/hook/pre_commit/pronto.rb +21 -0
- data/lib/overcommit/hook/pre_commit/pycodestyle.rb +21 -0
- data/lib/overcommit/hook/pre_commit/pydocstyle.rb +21 -0
- data/lib/overcommit/installer.rb +1 -2
- data/lib/overcommit/version.rb +1 -1
- data/template-dir/hooks/pre-rebase +0 -0
- metadata +16 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ae52de060fc3a851e75bd8933c88d554ef099b2c
|
|
4
|
+
data.tar.gz: d8c64f104d539cb9feff13df03aea820b61ede3b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 601925f353e7745b2461637f4a3d78483593e64e4c227601f0f1df5ff249ac903019fa47c90ec34521b0e416a7108d6bd7446b5aa56a48a1ab35e39359756aad
|
|
7
|
+
data.tar.gz: 8b6d27df807ce37e4eb94fddb105d22aa39f3b4cc9a233732f005792c8207ce914ddf40ddae87f5394eafda3aab97ff2d39b3951c69c8775147af58766c8cb57
|
data/bin/overcommit
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
# Check if Overcommit should invoke a Bundler context for loading gems
|
|
4
4
|
require 'yaml'
|
|
5
|
-
# rubocop:disable Style/RescueModifier
|
|
6
5
|
if gemfile = YAML.load_file('.overcommit.yml')['gemfile'] rescue nil
|
|
7
6
|
ENV['BUNDLE_GEMFILE'] = gemfile
|
|
8
7
|
require 'bundler'
|
|
@@ -22,9 +21,14 @@ if gemfile = YAML.load_file('.overcommit.yml')['gemfile'] rescue nil
|
|
|
22
21
|
puts "Problem loading '#{gemfile}': #{ex.message}"
|
|
23
22
|
puts "Try running:\nbundle install --gemfile=#{gemfile}" if ex.is_a?(Bundler::GemNotFound)
|
|
24
23
|
exit 78 # EX_CONFIG
|
|
24
|
+
rescue Gem::LoadError => ex
|
|
25
|
+
# Handle case where user is executing overcommit without `bundle exec` and
|
|
26
|
+
# whose local Gemfile has a gem requirement that does not match a gem
|
|
27
|
+
# requirement of the installed version of Overcommit.
|
|
28
|
+
raise unless ex.message =~ /already activated/i
|
|
29
|
+
exec('bundle', 'exec', $0, *ARGV)
|
|
25
30
|
end
|
|
26
31
|
end
|
|
27
|
-
# rubocop:enable Style/RescueModifier
|
|
28
32
|
|
|
29
33
|
begin
|
|
30
34
|
require 'overcommit/cli'
|
data/config/default.yml
CHANGED
|
@@ -283,11 +283,19 @@ PreCommit:
|
|
|
283
283
|
install_command: 'go get golang.org/x/tools/cmd/vet'
|
|
284
284
|
include: '**/*.go'
|
|
285
285
|
|
|
286
|
+
Hadolint:
|
|
287
|
+
enabled: false
|
|
288
|
+
description: 'Analyze with hadolint'
|
|
289
|
+
required_executable: 'hadolint'
|
|
290
|
+
include:
|
|
291
|
+
- '**/Dockerfile*'
|
|
292
|
+
|
|
286
293
|
HamlLint:
|
|
287
294
|
enabled: false
|
|
288
295
|
description: 'Analyze with haml-lint'
|
|
289
296
|
required_executable: 'haml-lint'
|
|
290
297
|
install_command: 'gem install haml-lint'
|
|
298
|
+
flags: ['--no-summary']
|
|
291
299
|
include: '**/*.haml'
|
|
292
300
|
|
|
293
301
|
HardTabs:
|
|
@@ -296,6 +304,9 @@ PreCommit:
|
|
|
296
304
|
quiet: true
|
|
297
305
|
required_executable: 'grep'
|
|
298
306
|
flags: ['-IHn', "\t"]
|
|
307
|
+
exclude:
|
|
308
|
+
- '**/Makefile'
|
|
309
|
+
- '**/*.go'
|
|
299
310
|
|
|
300
311
|
Hlint:
|
|
301
312
|
enabled: false
|
|
@@ -375,6 +386,21 @@ PreCommit:
|
|
|
375
386
|
install_command: 'gem install json'
|
|
376
387
|
include: '**/*.json'
|
|
377
388
|
|
|
389
|
+
LicenseFinder:
|
|
390
|
+
enabled: false
|
|
391
|
+
description: 'Analyze with LicenseFinder'
|
|
392
|
+
required_executable: 'license_finder'
|
|
393
|
+
install_command: 'gem install license_finder'
|
|
394
|
+
include:
|
|
395
|
+
- 'Gemfile'
|
|
396
|
+
- 'requirements.txt'
|
|
397
|
+
- 'package.json'
|
|
398
|
+
- 'pom.xml'
|
|
399
|
+
- 'build.gradle'
|
|
400
|
+
- 'bower.json'
|
|
401
|
+
- 'Podfile'
|
|
402
|
+
- 'rebar.config'
|
|
403
|
+
|
|
378
404
|
LicenseHeader:
|
|
379
405
|
enabled: false
|
|
380
406
|
license_file: 'LICENSE.txt'
|
|
@@ -408,20 +434,27 @@ PreCommit:
|
|
|
408
434
|
flags: ['-t']
|
|
409
435
|
include: '**/nginx.conf'
|
|
410
436
|
|
|
411
|
-
Pep257:
|
|
437
|
+
Pep257: # Deprecated – use Pydocstyle instead.
|
|
412
438
|
enabled: false
|
|
413
439
|
description: 'Analyze docstrings with pep257'
|
|
414
440
|
required_executable: 'pep257'
|
|
415
441
|
install_command: 'pip install pep257'
|
|
416
442
|
include: '**/*.py'
|
|
417
443
|
|
|
418
|
-
Pep8:
|
|
444
|
+
Pep8: # Deprecated – use Pycodestyle instead.
|
|
419
445
|
enabled: false
|
|
420
446
|
description: 'Analyze with pep8'
|
|
421
447
|
required_executable: 'pep8'
|
|
422
448
|
install_command: 'pip install pep8'
|
|
423
449
|
include: '**/*.py'
|
|
424
450
|
|
|
451
|
+
Pronto:
|
|
452
|
+
enabled: false
|
|
453
|
+
description: 'Analyzing with pronto'
|
|
454
|
+
required_executable: 'pronto'
|
|
455
|
+
install_command: 'gem install pronto'
|
|
456
|
+
flags: ['run', '--staged', '--exit-code']
|
|
457
|
+
|
|
425
458
|
PuppetLint:
|
|
426
459
|
enabled: false
|
|
427
460
|
description: 'Analyze with puppet-lint'
|
|
@@ -433,6 +466,20 @@ PreCommit:
|
|
|
433
466
|
- '--error-level=all'
|
|
434
467
|
include: '**/*.pp'
|
|
435
468
|
|
|
469
|
+
Pycodestyle:
|
|
470
|
+
enabled: false
|
|
471
|
+
description: 'Analyze with pycodestyle'
|
|
472
|
+
required_executable: 'pycodestyle'
|
|
473
|
+
install_command: 'pip install pycodestyle'
|
|
474
|
+
include: '**/*.py'
|
|
475
|
+
|
|
476
|
+
Pydocstyle:
|
|
477
|
+
enabled: false
|
|
478
|
+
description: 'Analyze docstrings with pydocstyle'
|
|
479
|
+
required_executable: 'pydocstyle'
|
|
480
|
+
install_command: 'pip install pydocstyle'
|
|
481
|
+
include: '**/*.py'
|
|
482
|
+
|
|
436
483
|
Pyflakes:
|
|
437
484
|
enabled: false
|
|
438
485
|
description: 'Analyze with pyflakes'
|
|
@@ -41,7 +41,7 @@ module Overcommit
|
|
|
41
41
|
@concurrency ||=
|
|
42
42
|
begin
|
|
43
43
|
cores = Overcommit::Utils.processor_count
|
|
44
|
-
content = @hash.fetch('concurrency', '
|
|
44
|
+
content = @hash.fetch('concurrency', '%<processors>d')
|
|
45
45
|
if content.is_a?(String)
|
|
46
46
|
concurrency_expr = content % { processors: cores }
|
|
47
47
|
|
|
@@ -112,7 +112,7 @@ module Overcommit
|
|
|
112
112
|
# Returns the built-in hooks that have been enabled for a hook type.
|
|
113
113
|
def enabled_builtin_hooks(hook_context)
|
|
114
114
|
@hash[hook_context.hook_class_name].keys.
|
|
115
|
-
|
|
115
|
+
reject { |hook_name| hook_name == 'ALL' }.
|
|
116
116
|
select { |hook_name| built_in_hook?(hook_context, hook_name) }.
|
|
117
117
|
select { |hook_name| hook_enabled?(hook_context, hook_name) }
|
|
118
118
|
end
|
|
@@ -120,7 +120,7 @@ module Overcommit
|
|
|
120
120
|
# Returns the ad hoc hooks that have been enabled for a hook type.
|
|
121
121
|
def enabled_ad_hoc_hooks(hook_context)
|
|
122
122
|
@hash[hook_context.hook_class_name].keys.
|
|
123
|
-
|
|
123
|
+
reject { |hook_name| hook_name == 'ALL' }.
|
|
124
124
|
select { |hook_name| ad_hoc_hook?(hook_context, hook_name) }.
|
|
125
125
|
select { |hook_name| hook_enabled?(hook_context, hook_name) }
|
|
126
126
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require 'overcommit/utils'
|
|
2
|
+
|
|
1
3
|
module Overcommit
|
|
2
4
|
# Get configuration options from git
|
|
3
5
|
module GitConfig
|
|
@@ -8,5 +10,11 @@ module Overcommit
|
|
|
8
10
|
char = '#' if char == ''
|
|
9
11
|
char
|
|
10
12
|
end
|
|
13
|
+
|
|
14
|
+
def hooks_path
|
|
15
|
+
path = `git config --get core.hooksPath`.chomp
|
|
16
|
+
return File.join(Overcommit::Utils.repo_root, '.git', 'hooks') if path.empty?
|
|
17
|
+
File.absolute_path(path)
|
|
18
|
+
end
|
|
11
19
|
end
|
|
12
20
|
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Overcommit::Hook::PreCommit
|
|
2
|
+
# Runs `hadolint` against any modified Dockefile files.
|
|
3
|
+
#
|
|
4
|
+
# @see http://hadolint.lukasmartinelli.ch/
|
|
5
|
+
class Hadolint < Base
|
|
6
|
+
def run
|
|
7
|
+
output = ''
|
|
8
|
+
success = true
|
|
9
|
+
|
|
10
|
+
# hadolint doesn't accept multiple arguments
|
|
11
|
+
applicable_files.each do |dockerfile|
|
|
12
|
+
result = execute(command, args: Array(dockerfile))
|
|
13
|
+
output += result.stdout
|
|
14
|
+
success &&= result.success?
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
return :pass if success
|
|
18
|
+
|
|
19
|
+
extract_messages(
|
|
20
|
+
output.split("\n"),
|
|
21
|
+
/^(?<file>[^:]+):(?<line>\d+)/,
|
|
22
|
+
)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module Overcommit::Hook::PreCommit
|
|
2
|
+
# Runs LicenseFinder if any of your package manager declaration files have changed
|
|
3
|
+
# See more about LicenseFinder at https://github.com/pivotal/LicenseFinde
|
|
4
|
+
class LicenseFinder < Base
|
|
5
|
+
def run
|
|
6
|
+
result = execute(command)
|
|
7
|
+
return :pass if result.success?
|
|
8
|
+
output = result.stdout + result.stderr
|
|
9
|
+
[:fail, output]
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -8,18 +8,16 @@ module Overcommit::Hook::PreCommit
|
|
|
8
8
|
|
|
9
9
|
offending_files.map do |file_name|
|
|
10
10
|
file = File.open(file_name)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
#
|
|
16
|
-
next unless line.end_with?("\n", "\r")
|
|
17
|
-
|
|
11
|
+
begin
|
|
12
|
+
messages += check_file(file, file_name)
|
|
13
|
+
rescue ArgumentError => ex
|
|
14
|
+
# File is likely a binary file which this check should ignore, but
|
|
15
|
+
# print a warning just in case
|
|
18
16
|
messages << Overcommit::Hook::Message.new(
|
|
19
|
-
:
|
|
17
|
+
:warning,
|
|
20
18
|
file_name,
|
|
21
19
|
file.lineno,
|
|
22
|
-
"#{file_name}:#{file.lineno}:#{
|
|
20
|
+
"#{file_name}:#{file.lineno}:#{ex.message}"
|
|
23
21
|
)
|
|
24
22
|
end
|
|
25
23
|
end
|
|
@@ -29,6 +27,27 @@ module Overcommit::Hook::PreCommit
|
|
|
29
27
|
|
|
30
28
|
private
|
|
31
29
|
|
|
30
|
+
def check_file(file, file_name)
|
|
31
|
+
messages_for_file = []
|
|
32
|
+
|
|
33
|
+
file.each_line do |line|
|
|
34
|
+
# Remove configured line-ending
|
|
35
|
+
line.gsub!(/#{config['eol']}/, '')
|
|
36
|
+
|
|
37
|
+
# Detect any left over line-ending characters
|
|
38
|
+
next unless line.end_with?("\n", "\r")
|
|
39
|
+
|
|
40
|
+
messages_for_file << Overcommit::Hook::Message.new(
|
|
41
|
+
:error,
|
|
42
|
+
file_name,
|
|
43
|
+
file.lineno,
|
|
44
|
+
"#{file_name}:#{file.lineno}:#{line.inspect}"
|
|
45
|
+
)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
messages_for_file
|
|
49
|
+
end
|
|
50
|
+
|
|
32
51
|
def offending_files
|
|
33
52
|
result = execute(%w[git ls-files --eol -z --], args: applicable_files)
|
|
34
53
|
raise 'Unable to access git tree' unless result.success?
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Overcommit::Hook::PreCommit
|
|
2
|
+
# Runs `pronto`
|
|
3
|
+
#
|
|
4
|
+
# @see https://github.com/mmozuras/pronto
|
|
5
|
+
class Pronto < Base
|
|
6
|
+
MESSAGE_TYPE_CATEGORIZER = lambda do |type|
|
|
7
|
+
type.include?('E') ? :error : :warning
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def run
|
|
11
|
+
result = execute(command)
|
|
12
|
+
return :pass if result.success?
|
|
13
|
+
|
|
14
|
+
extract_messages(
|
|
15
|
+
result.stdout.split("\n"),
|
|
16
|
+
/^(?<file>(?:\w:)?[^:]+):(?<line>\d+) (?<type>[^ ]+)/,
|
|
17
|
+
MESSAGE_TYPE_CATEGORIZER,
|
|
18
|
+
)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Overcommit::Hook::PreCommit
|
|
2
|
+
# Runs `pycodestyle` against any modified Python files.
|
|
3
|
+
#
|
|
4
|
+
# @see https://pypi.python.org/pypi/pycodestyle
|
|
5
|
+
class Pycodestyle < Base
|
|
6
|
+
def run
|
|
7
|
+
result = execute(command, args: applicable_files)
|
|
8
|
+
output = result.stdout.chomp
|
|
9
|
+
|
|
10
|
+
return :pass if result.success? && output.empty?
|
|
11
|
+
|
|
12
|
+
# example message:
|
|
13
|
+
# path/to/file.py:88:5: E301 expected 1 blank line, found 0
|
|
14
|
+
extract_messages(
|
|
15
|
+
output.split("\n"),
|
|
16
|
+
/^(?<file>(?:\w:)?[^:]+):(?<line>\d+):\d+:\s(?<type>E|W)/,
|
|
17
|
+
lambda { |type| type.include?('W') ? :warning : :error }
|
|
18
|
+
)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Overcommit::Hook::PreCommit
|
|
2
|
+
# Runs `pydocstyle` against any modified Python files.
|
|
3
|
+
#
|
|
4
|
+
# @see https://pypi.python.org/pypi/pydocstyle
|
|
5
|
+
class Pydocstyle < Base
|
|
6
|
+
def run
|
|
7
|
+
result = execute(command, args: applicable_files)
|
|
8
|
+
return :pass if result.success?
|
|
9
|
+
|
|
10
|
+
output = result.stderr.chomp
|
|
11
|
+
|
|
12
|
+
# example message:
|
|
13
|
+
# path/to/file.py:1 in public method `foo`:
|
|
14
|
+
# D102: Docstring missing
|
|
15
|
+
extract_messages(
|
|
16
|
+
output.gsub(/:\s+/, ': ').split("\n"),
|
|
17
|
+
/^(?<file>(?:\w:)?[^:]+):(?<line>\d+)/
|
|
18
|
+
)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
data/lib/overcommit/installer.rb
CHANGED
data/lib/overcommit/version.rb
CHANGED
|
File without changes
|
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.40.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: 2017-
|
|
12
|
+
date: 2017-06-29 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: childprocess
|
|
@@ -17,14 +17,20 @@ dependencies:
|
|
|
17
17
|
requirements:
|
|
18
18
|
- - "~>"
|
|
19
19
|
- !ruby/object:Gem::Version
|
|
20
|
-
version: 0.6
|
|
20
|
+
version: '0.6'
|
|
21
|
+
- - ">="
|
|
22
|
+
- !ruby/object:Gem::Version
|
|
23
|
+
version: 0.6.3
|
|
21
24
|
type: :runtime
|
|
22
25
|
prerelease: false
|
|
23
26
|
version_requirements: !ruby/object:Gem::Requirement
|
|
24
27
|
requirements:
|
|
25
28
|
- - "~>"
|
|
26
29
|
- !ruby/object:Gem::Version
|
|
27
|
-
version: 0.6
|
|
30
|
+
version: '0.6'
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: 0.6.3
|
|
28
34
|
- !ruby/object:Gem::Dependency
|
|
29
35
|
name: iniparse
|
|
30
36
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -122,6 +128,7 @@ files:
|
|
|
122
128
|
- lib/overcommit/hook/pre_commit/forbidden_branches.rb
|
|
123
129
|
- lib/overcommit/hook/pre_commit/go_lint.rb
|
|
124
130
|
- lib/overcommit/hook/pre_commit/go_vet.rb
|
|
131
|
+
- lib/overcommit/hook/pre_commit/hadolint.rb
|
|
125
132
|
- lib/overcommit/hook/pre_commit/haml_lint.rb
|
|
126
133
|
- lib/overcommit/hook/pre_commit/hard_tabs.rb
|
|
127
134
|
- lib/overcommit/hook/pre_commit/hlint.rb
|
|
@@ -134,6 +141,7 @@ files:
|
|
|
134
141
|
- lib/overcommit/hook/pre_commit/jscs.rb
|
|
135
142
|
- lib/overcommit/hook/pre_commit/jsl.rb
|
|
136
143
|
- lib/overcommit/hook/pre_commit/json_syntax.rb
|
|
144
|
+
- lib/overcommit/hook/pre_commit/license_finder.rb
|
|
137
145
|
- lib/overcommit/hook/pre_commit/license_header.rb
|
|
138
146
|
- lib/overcommit/hook/pre_commit/line_endings.rb
|
|
139
147
|
- lib/overcommit/hook/pre_commit/local_paths_in_gemfile.rb
|
|
@@ -142,7 +150,10 @@ files:
|
|
|
142
150
|
- lib/overcommit/hook/pre_commit/nginx_test.rb
|
|
143
151
|
- lib/overcommit/hook/pre_commit/pep257.rb
|
|
144
152
|
- lib/overcommit/hook/pre_commit/pep8.rb
|
|
153
|
+
- lib/overcommit/hook/pre_commit/pronto.rb
|
|
145
154
|
- lib/overcommit/hook/pre_commit/puppet_lint.rb
|
|
155
|
+
- lib/overcommit/hook/pre_commit/pycodestyle.rb
|
|
156
|
+
- lib/overcommit/hook/pre_commit/pydocstyle.rb
|
|
146
157
|
- lib/overcommit/hook/pre_commit/pyflakes.rb
|
|
147
158
|
- lib/overcommit/hook/pre_commit/pylint.rb
|
|
148
159
|
- lib/overcommit/hook/pre_commit/python_flake8.rb
|
|
@@ -246,7 +257,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
246
257
|
version: '0'
|
|
247
258
|
requirements: []
|
|
248
259
|
rubyforge_project:
|
|
249
|
-
rubygems_version: 2.6.
|
|
260
|
+
rubygems_version: 2.6.12
|
|
250
261
|
signing_key:
|
|
251
262
|
specification_version: 4
|
|
252
263
|
summary: Git hook manager
|