overcommit 0.29.1 → 0.30.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 91af002cf7828227351dd72b5c6bf2b27e3b217d
4
- data.tar.gz: 025444e49ce27a05f6fc54134ae0ce70a466f851
3
+ metadata.gz: 6b041ebaa80bcfe3013027b461fd01453c6b9206
4
+ data.tar.gz: aa64ece4843d4d6153850d9e8e2a3bc14399257c
5
5
  SHA512:
6
- metadata.gz: 602cf07b0687009d092330706d3f6d54179d2cbfcd1d58fb3cfa3c9fe92195ee1a0af3d452d5649666e534d5d352ab2ca52d5dd1711bda55ec1f20d7bc5fbbcc
7
- data.tar.gz: 642bc0ec26c0af5dcfa44a30ea930f847f1cda71dd6bcd0d78003624f5b10c3c227918dea4d68d110c4b5844e7c40fe2a4538848685d185f28297516bddc4f62
6
+ metadata.gz: c2c6d61a99022f38a43bcaa286bb5907fda839325d0334112450e45226b52b51b3b52841121ef767dbabaed8bec3d595a8129c9fabbee2691eff8f994fea9a68
7
+ data.tar.gz: c36a4c528cb64b8387caeeedee2dda72207da0d42fc4c92b849fd9d9c0e7ee5bfa2a3a998165fdea66a4d7c91632dcc5521b2e7d47cffc3550910480e99ad446
@@ -188,6 +188,15 @@ PreCommit:
188
188
  install_command: 'npm install -g csslint'
189
189
  include: '**/*.css'
190
190
 
191
+ Dogma:
192
+ enabled: false
193
+ description: 'Analyzing with dogma'
194
+ required_executable: 'mix'
195
+ flags: ['dogma']
196
+ include:
197
+ - '**/*.ex'
198
+ - '**/*.exs'
199
+
191
200
  EsLint:
192
201
  enabled: false
193
202
  description: 'Analyzing with ESLint'
@@ -379,6 +388,12 @@ PreCommit:
379
388
  install_command: 'pip install flake8'
380
389
  include: '**/*.py'
381
390
 
391
+ RailsBestPractices:
392
+ enabled: false
393
+ description: 'Analyzing with RailsBestPractices'
394
+ required_executable: 'rails_best_practices'
395
+ install_command: 'gem install rails_best_practices'
396
+
382
397
  RailsSchemaUpToDate:
383
398
  enabled: false
384
399
  description: 'Checking if database schema is up to date'
@@ -774,6 +789,12 @@ PrePush:
774
789
  description: 'Running RSpec test suite'
775
790
  required_executable: 'rspec'
776
791
 
792
+ Minitest:
793
+ enabled: false
794
+ description: 'Running Minitest test suite'
795
+ command: ['ruby', '-Ilib:test', 'test']
796
+ required_library: 'minitest'
797
+
777
798
  # Hooks that run during `git rebase`, before any commits are rebased.
778
799
  # If a hook fails, the rebase is aborted.
779
800
  PreRebase:
@@ -193,7 +193,8 @@ module Overcommit
193
193
  end
194
194
 
195
195
  def run_all
196
- context = Overcommit::HookContext.create('run-all', config, @arguments, @input)
196
+ empty_stdin = File.open(File::NULL) # pre-commit hooks don't take input
197
+ context = Overcommit::HookContext.create('run-all', config, @arguments, empty_stdin)
197
198
  config.apply_environment!(context, ENV)
198
199
 
199
200
  printer = Overcommit::Printer.new(log, context)
@@ -184,7 +184,8 @@ module Overcommit::Hook
184
184
  def check_for_executable
185
185
  return unless required_executable && !in_path?(required_executable)
186
186
 
187
- output = "'#{required_executable}' is not installed (or is not in your PATH)"
187
+ output = "'#{required_executable}' is not installed, not in your PATH, " \
188
+ 'or does not have execute permissions'
188
189
  output << install_command_prompt
189
190
 
190
191
  output
@@ -7,7 +7,7 @@ module Overcommit::Hook::CommitMsg
7
7
 
8
8
  @errors = []
9
9
 
10
- find_errors_in_subject(commit_message_lines.first)
10
+ find_errors_in_subject(commit_message_lines.first.chomp)
11
11
  find_errors_in_body(commit_message_lines)
12
12
 
13
13
  return :warn, @errors.join("\n") if @errors.any?
@@ -0,0 +1,31 @@
1
+ module Overcommit::Hook::PreCommit
2
+ # Runs `dogma` against any modified ex files.
3
+ #
4
+ # @see https://github.com/lpil/dogma
5
+ class Dogma < Base
6
+ def run
7
+ result = execute command
8
+ return :pass if result.success?
9
+
10
+ messages = []
11
+ # example message:
12
+ # == web/channels/user_socket.ex ==
13
+ # 26: LineLength: Line length should not exceed 80 chars (was 83).
14
+ # 1: ModuleDoc: Module Sample.UserSocket is missing a @moduledoc.
15
+ output = result.stdout.chomp.match(/(==.+)/m)
16
+
17
+ if output
18
+ output.captures.first.split(/\n\n/).each do |error_group|
19
+ errors = error_group.split /\n/
20
+ file = errors.shift.gsub /[ =]/, ''
21
+ errors.each do |error|
22
+ line = error.split(': ').first
23
+ messages << Overcommit::Hook::Message.new(:error, file, line, "#{file}: #{error}")
24
+ end
25
+ end
26
+ end
27
+
28
+ messages
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,32 @@
1
+ module Overcommit
2
+ module Hook
3
+ module PreCommit
4
+ # Runs `rails_best_practices` against Ruby files
5
+ #
6
+ # @see https://github.com/railsbp/rails_best_practices
7
+ class RailsBestPractices < Base
8
+ ERROR_REGEXP = /^(?<file>(?:\w:)?[^:]+):(?<line>\d+)\s-\s(?<type>.+)/
9
+
10
+ def run
11
+ result = execute(command)
12
+
13
+ return :pass if result.success?
14
+ return [:fail, result.stderr] unless result.stderr.empty?
15
+
16
+ extract_messages(
17
+ filter_output(result.stdout),
18
+ ERROR_REGEXP
19
+ )
20
+ end
21
+
22
+ private
23
+
24
+ def filter_output(stdout)
25
+ stdout.split("\n").select do |message|
26
+ message.match ERROR_REGEXP
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -10,6 +10,7 @@ module Overcommit::Hook::PreCommit
10
10
  def run
11
11
  result = execute(command, args: applicable_files)
12
12
  return :pass if result.success?
13
+ return [:fail, result.stderr] unless result.stderr.empty?
13
14
 
14
15
  extract_messages(
15
16
  result.stdout.split("\n"),
@@ -0,0 +1,14 @@
1
+ module Overcommit::Hook::PrePush
2
+ # Runs `minitest` test suite before push
3
+ #
4
+ # @see https://github.com/seattlerb/minitest
5
+ class Minitest < Base
6
+ def run
7
+ result = execute(command)
8
+ return :pass if result.success?
9
+
10
+ output = result.stdout + result.stderr
11
+ [:fail, output]
12
+ end
13
+ end
14
+ end
@@ -30,5 +30,7 @@ module Overcommit
30
30
  @os ||= ::RbConfig::CONFIG['host_os']
31
31
  end
32
32
  end
33
+
34
+ SEPARATOR = self.windows? ? '\\' : File::SEPARATOR
33
35
  end
34
36
  end
@@ -58,7 +58,7 @@ module Overcommit::Utils
58
58
  end
59
59
 
60
60
  def win32_fix_pathsep(path)
61
- path.tr('/', '\\')
61
+ path.tr(File::SEPARATOR, Overcommit::OS::SEPARATOR)
62
62
  end
63
63
 
64
64
  def win32_symlink?(dir_output)
@@ -1,4 +1,4 @@
1
1
  # Defines the gem version.
2
2
  module Overcommit
3
- VERSION = '0.29.1'
3
+ VERSION = '0.30.0'
4
4
  end
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.29.1
4
+ version: 0.30.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-11-18 00:00:00.000000000 Z
12
+ date: 2015-12-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: childprocess
@@ -137,6 +137,7 @@ files:
137
137
  - lib/overcommit/hook/pre_commit/chamber_security.rb
138
138
  - lib/overcommit/hook/pre_commit/coffee_lint.rb
139
139
  - lib/overcommit/hook/pre_commit/css_lint.rb
140
+ - lib/overcommit/hook/pre_commit/dogma.rb
140
141
  - lib/overcommit/hook/pre_commit/es_lint.rb
141
142
  - lib/overcommit/hook/pre_commit/execute_permissions.rb
142
143
  - lib/overcommit/hook/pre_commit/go_lint.rb
@@ -162,6 +163,7 @@ files:
162
163
  - lib/overcommit/hook/pre_commit/pyflakes.rb
163
164
  - lib/overcommit/hook/pre_commit/pylint.rb
164
165
  - lib/overcommit/hook/pre_commit/python_flake8.rb
166
+ - lib/overcommit/hook/pre_commit/rails_best_practices.rb
165
167
  - lib/overcommit/hook/pre_commit/rails_schema_up_to_date.rb
166
168
  - lib/overcommit/hook/pre_commit/reek.rb
167
169
  - lib/overcommit/hook/pre_commit/rubo_cop.rb
@@ -183,6 +185,7 @@ files:
183
185
  - lib/overcommit/hook/pre_commit/xml_syntax.rb
184
186
  - lib/overcommit/hook/pre_commit/yaml_syntax.rb
185
187
  - lib/overcommit/hook/pre_push/base.rb
188
+ - lib/overcommit/hook/pre_push/minitest.rb
186
189
  - lib/overcommit/hook/pre_push/protected_branches.rb
187
190
  - lib/overcommit/hook/pre_push/r_spec.rb
188
191
  - lib/overcommit/hook/pre_rebase/base.rb