overcommit 0.39.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 688cc14559f6df12a77e50f70f478be5b3118d07
4
- data.tar.gz: 787514eb5c006ffb8b9a5c48bf32b74c59c8f994
3
+ metadata.gz: ae52de060fc3a851e75bd8933c88d554ef099b2c
4
+ data.tar.gz: d8c64f104d539cb9feff13df03aea820b61ede3b
5
5
  SHA512:
6
- metadata.gz: 9cf7cfc7aba8ad00f45da2eaa571256ef2c3d9ebd2115c098f41d2ce816cf70dfcc2ba6a0f351d60f02cc34f23ee0fa5792b8b0d0d714d7d4a9ca832db6078f6
7
- data.tar.gz: 8bdd432dd5e873efd021f26128517d592ae94e7ebc6ff3241a50c23e3dbe1305c4da67aaf35fad338db108dcfdb625ea0574d50df9f7eeee64c55430f6a348f5
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,6 +283,13 @@ 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'
@@ -297,6 +304,9 @@ PreCommit:
297
304
  quiet: true
298
305
  required_executable: 'grep'
299
306
  flags: ['-IHn', "\t"]
307
+ exclude:
308
+ - '**/Makefile'
309
+ - '**/*.go'
300
310
 
301
311
  Hlint:
302
312
  enabled: false
@@ -376,6 +386,21 @@ PreCommit:
376
386
  install_command: 'gem install json'
377
387
  include: '**/*.json'
378
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
+
379
404
  LicenseHeader:
380
405
  enabled: false
381
406
  license_file: 'LICENSE.txt'
@@ -409,20 +434,27 @@ PreCommit:
409
434
  flags: ['-t']
410
435
  include: '**/nginx.conf'
411
436
 
412
- Pep257:
437
+ Pep257: # Deprecated – use Pydocstyle instead.
413
438
  enabled: false
414
439
  description: 'Analyze docstrings with pep257'
415
440
  required_executable: 'pep257'
416
441
  install_command: 'pip install pep257'
417
442
  include: '**/*.py'
418
443
 
419
- Pep8:
444
+ Pep8: # Deprecated – use Pycodestyle instead.
420
445
  enabled: false
421
446
  description: 'Analyze with pep8'
422
447
  required_executable: 'pep8'
423
448
  install_command: 'pip install pep8'
424
449
  include: '**/*.py'
425
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
+
426
458
  PuppetLint:
427
459
  enabled: false
428
460
  description: 'Analyze with puppet-lint'
@@ -434,6 +466,20 @@ PreCommit:
434
466
  - '--error-level=all'
435
467
  include: '**/*.pp'
436
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
+
437
483
  Pyflakes:
438
484
  enabled: false
439
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', '%{processors}')
44
+ content = @hash.fetch('concurrency', '%<processors>d')
45
45
  if content.is_a?(String)
46
46
  concurrency_expr = content % { processors: cores }
47
47
 
@@ -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
- file.each_line do |line|
12
- # remove configured line-ending
13
- line.gsub!(/#{config['eol']}/, '')
14
-
15
- # detect any left over line-ending characters
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
- :error,
17
+ :warning,
20
18
  file_name,
21
19
  file.lineno,
22
- "#{file_name}:#{file.lineno}:#{line.inspect}"
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
@@ -65,8 +65,7 @@ module Overcommit
65
65
  end
66
66
 
67
67
  def hooks_path
68
- absolute_target = File.expand_path(@target)
69
- File.join(Overcommit::Utils.git_dir(absolute_target), 'hooks')
68
+ @hooks_path ||= Dir.chdir(@target) { GitConfig.hooks_path }
70
69
  end
71
70
 
72
71
  def old_hooks_path
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Defines the gem version.
4
4
  module Overcommit
5
- VERSION = '0.39.1'.freeze
5
+ VERSION = '0.40.0'.freeze
6
6
  end
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.39.1
4
+ version: 0.40.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brigade Engineering
@@ -9,13 +9,16 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-04-07 00:00:00.000000000 Z
12
+ date: 2017-06-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: childprocess
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
18
  - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '0.6'
21
+ - - ">="
19
22
  - !ruby/object:Gem::Version
20
23
  version: 0.6.3
21
24
  type: :runtime
@@ -23,6 +26,9 @@ dependencies:
23
26
  version_requirements: !ruby/object:Gem::Requirement
24
27
  requirements:
25
28
  - - "~>"
29
+ - !ruby/object:Gem::Version
30
+ version: '0.6'
31
+ - - ">="
26
32
  - !ruby/object:Gem::Version
27
33
  version: 0.6.3
28
34
  - !ruby/object:Gem::Dependency
@@ -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,9 +257,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
246
257
  version: '0'
247
258
  requirements: []
248
259
  rubyforge_project:
249
- rubygems_version: 2.5.1
260
+ rubygems_version: 2.6.12
250
261
  signing_key:
251
262
  specification_version: 4
252
263
  summary: Git hook manager
253
264
  test_files: []
254
- has_rdoc: