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 +4 -4
- data/config/default.yml +21 -0
- data/lib/overcommit/cli.rb +2 -1
- data/lib/overcommit/hook/base.rb +2 -1
- data/lib/overcommit/hook/commit_msg/text_width.rb +1 -1
- data/lib/overcommit/hook/pre_commit/dogma.rb +31 -0
- data/lib/overcommit/hook/pre_commit/rails_best_practices.rb +32 -0
- data/lib/overcommit/hook/pre_commit/rubo_cop.rb +1 -0
- data/lib/overcommit/hook/pre_push/minitest.rb +14 -0
- data/lib/overcommit/os.rb +2 -0
- data/lib/overcommit/utils/file_utils.rb +1 -1
- data/lib/overcommit/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b041ebaa80bcfe3013027b461fd01453c6b9206
|
4
|
+
data.tar.gz: aa64ece4843d4d6153850d9e8e2a3bc14399257c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2c6d61a99022f38a43bcaa286bb5907fda839325d0334112450e45226b52b51b3b52841121ef767dbabaed8bec3d595a8129c9fabbee2691eff8f994fea9a68
|
7
|
+
data.tar.gz: c36a4c528cb64b8387caeeedee2dda72207da0d42fc4c92b849fd9d9c0e7ee5bfa2a3a998165fdea66a4d7c91632dcc5521b2e7d47cffc3550910480e99ad446
|
data/config/default.yml
CHANGED
@@ -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:
|
data/lib/overcommit/cli.rb
CHANGED
@@ -193,7 +193,8 @@ module Overcommit
|
|
193
193
|
end
|
194
194
|
|
195
195
|
def run_all
|
196
|
-
|
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)
|
data/lib/overcommit/hook/base.rb
CHANGED
@@ -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
|
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
|
@@ -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
|
data/lib/overcommit/os.rb
CHANGED
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.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-
|
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
|