overcommit 0.48.1 → 0.49.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 +24 -0
- data/lib/overcommit/hook/pre_commit/code_spell_check.rb +36 -0
- data/lib/overcommit/hook/pre_commit/mdl.rb +11 -7
- data/lib/overcommit/hook/pre_commit/ruby_syntax.rb +27 -0
- data/lib/overcommit/hook/prepare_commit_msg/replace_branch.rb +15 -10
- data/lib/overcommit/hook_runner.rb +3 -6
- data/lib/overcommit/version.rb +1 -1
- metadata +10 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a28cd7dfaf56d9588e2f9f789f49f4da01e50ebaa835a18d3d2f00c76863901d
|
4
|
+
data.tar.gz: 3112089cea167f58128d085f5c02cd9ec3589f6b3ac1cbb934e6d6a9d8c7982d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e282603906588c02990acb714d2b767599295b4fd66102a9a1a705fd57eca4ff4eee29772c03e33c2a632692167898837b469a909979e043cc3dce9c24dc0d67
|
7
|
+
data.tar.gz: 281d5bd19cdbd57a036bd9985764271b8616e673b12c796a9832150bb8fa7a779f7e59d332aa877b4eefdce0f2332923b2a4c7e6487ef4b7df259e8ad23c8d74
|
data/config/default.yml
CHANGED
@@ -222,6 +222,15 @@ PreCommit:
|
|
222
222
|
install_command: 'gem install chamber'
|
223
223
|
include: *chamber_settings_files
|
224
224
|
|
225
|
+
CodeSpellCheck:
|
226
|
+
enabled: false
|
227
|
+
description: 'Check if all your code is spell-checked correctly'
|
228
|
+
command: 'alfonsox'
|
229
|
+
install_command: 'gem install alfonsox'
|
230
|
+
include:
|
231
|
+
- '**/*.rb'
|
232
|
+
- '**/*.erb'
|
233
|
+
|
225
234
|
CoffeeLint:
|
226
235
|
enabled: false
|
227
236
|
description: 'Analyze with coffeelint'
|
@@ -477,6 +486,7 @@ PreCommit:
|
|
477
486
|
enabled: false
|
478
487
|
description: 'Analyze markdown files with mdl'
|
479
488
|
required_executable: 'mdl'
|
489
|
+
flags: ['--json']
|
480
490
|
install_command: 'gem install mdl'
|
481
491
|
include: '**/*.md'
|
482
492
|
|
@@ -674,6 +684,19 @@ PreCommit:
|
|
674
684
|
- '**/*.gemspec'
|
675
685
|
- '**/*.rb'
|
676
686
|
|
687
|
+
RubySyntax:
|
688
|
+
enabled: false
|
689
|
+
description: 'Check ruby syntax'
|
690
|
+
required_executable: 'ruby'
|
691
|
+
command: [
|
692
|
+
'ruby',
|
693
|
+
'-e',
|
694
|
+
'ARGV.each { |applicable_file| ruby_c_output = `ruby -c #{applicable_file}`; puts ruby_c_output unless $?.success? }'
|
695
|
+
]
|
696
|
+
include:
|
697
|
+
- '**/*.gemspec'
|
698
|
+
- '**/*.rb'
|
699
|
+
|
677
700
|
Scalariform:
|
678
701
|
enabled: false
|
679
702
|
description: 'Check formatting with Scalariform'
|
@@ -1192,6 +1215,7 @@ PrepareCommitMsg:
|
|
1192
1215
|
description: 'Prepends the commit message with text based on the branch name'
|
1193
1216
|
branch_pattern: '\A.*\w+[-_](\d+).*\z'
|
1194
1217
|
replacement_text: '[#\1]'
|
1218
|
+
skipped_commit_types: ['message', 'template', 'merge', 'squash']
|
1195
1219
|
on_fail: warn
|
1196
1220
|
|
1197
1221
|
# Hooks that run during `git push`, after remote refs have been updated but
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Overcommit::Hook::PreCommit
|
4
|
+
# Runs `alfonsox` spell-checking tool against any modified code file.
|
5
|
+
#
|
6
|
+
# @see https://github.com/diegojromerolopez/alfonsox
|
7
|
+
class CodeSpellCheck < Base
|
8
|
+
def run
|
9
|
+
# Create default file config if it does not exist
|
10
|
+
|
11
|
+
# Run spell-check
|
12
|
+
result = execute(command, args: applicable_files)
|
13
|
+
return :pass if result.success?
|
14
|
+
|
15
|
+
spellchecking_errors = result.stderr.split("\n")
|
16
|
+
spellchecking_errors.pop
|
17
|
+
|
18
|
+
error_messages(spellchecking_errors)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
# Create the error messages
|
24
|
+
def error_messages(spellchecking_errors)
|
25
|
+
messages = []
|
26
|
+
spellchecking_errors.each do |spellchecking_error_i|
|
27
|
+
error_location, word = spellchecking_error_i.split(' ')
|
28
|
+
error_file_path, line = error_location.split(':')
|
29
|
+
messages << Overcommit::Hook::Message.new(
|
30
|
+
:error, error_file_path, line, "#{error_location}: #{word}"
|
31
|
+
)
|
32
|
+
end
|
33
|
+
messages
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -5,8 +5,6 @@ module Overcommit::Hook::PreCommit
|
|
5
5
|
#
|
6
6
|
# @see https://github.com/mivok/markdownlint
|
7
7
|
class Mdl < Base
|
8
|
-
MESSAGE_REGEX = /^(?<file>(?:\w:)?[^:]+):(?<line>\d+):\s(?<msg>.+)/
|
9
|
-
|
10
8
|
def run
|
11
9
|
result = execute(command, args: applicable_files)
|
12
10
|
output = result.stdout.chomp
|
@@ -15,11 +13,17 @@ module Overcommit::Hook::PreCommit
|
|
15
13
|
return [:fail, result.stderr] unless result.stderr.empty?
|
16
14
|
|
17
15
|
# example message:
|
18
|
-
#
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
16
|
+
# [{"filename":"file1.md","line":1,"rule":"MD013","aliases":["line-length"],
|
17
|
+
# "description":"Line length"}]
|
18
|
+
json_messages = JSON.parse(output)
|
19
|
+
json_messages.map do |message|
|
20
|
+
Overcommit::Hook::Message.new(
|
21
|
+
:error,
|
22
|
+
message[:filename],
|
23
|
+
message[:line],
|
24
|
+
message[:description]
|
25
|
+
)
|
26
|
+
end
|
23
27
|
end
|
24
28
|
end
|
25
29
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Overcommit::Hook::PreCommit
|
4
|
+
# Runs `ruby -c` against all Ruby files.
|
5
|
+
#
|
6
|
+
class RubySyntax < Base
|
7
|
+
MESSAGE_TYPE_CATEGORIZER = lambda do |type|
|
8
|
+
type.match?(/^(syntax)?\s*error/) ? :error : :warning
|
9
|
+
end
|
10
|
+
|
11
|
+
def run
|
12
|
+
result = execute(command, args: applicable_files)
|
13
|
+
|
14
|
+
result_lines = result.stderr.split("\n")
|
15
|
+
|
16
|
+
return :pass if result_lines.length.zero?
|
17
|
+
|
18
|
+
# Example message:
|
19
|
+
# path/to/file.rb:1: syntax error, unexpected '^'
|
20
|
+
extract_messages(
|
21
|
+
result_lines,
|
22
|
+
/^(?<file>[^:]+):(?<line>\d+):\s*(?<type>[^,]+),\s*(?<message>.+)/,
|
23
|
+
MESSAGE_TYPE_CATEGORIZER
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -6,20 +6,21 @@ module Overcommit::Hook::PrepareCommitMsg
|
|
6
6
|
# the `branch_pattern` regex.
|
7
7
|
class ReplaceBranch < Base
|
8
8
|
def run
|
9
|
-
return :pass
|
10
|
-
|
9
|
+
return :pass if skipped_commit_types.include? commit_message_source
|
10
|
+
|
11
11
|
Overcommit::Utils.log.debug(
|
12
12
|
"Checking if '#{Overcommit::GitRepo.current_branch}' matches #{branch_pattern}"
|
13
13
|
)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
:warn
|
14
|
+
|
15
|
+
return :warn unless branch_pattern.match?(Overcommit::GitRepo.current_branch)
|
16
|
+
|
17
|
+
Overcommit::Utils.log.debug("Writing #{commit_message_filename} with #{new_template}")
|
18
|
+
|
19
|
+
modify_commit_message do |old_contents|
|
20
|
+
"#{new_template}\n#{old_contents}"
|
22
21
|
end
|
22
|
+
|
23
|
+
:pass
|
23
24
|
end
|
24
25
|
|
25
26
|
def new_template
|
@@ -48,5 +49,9 @@ module Overcommit::Hook::PrepareCommitMsg
|
|
48
49
|
def replacement_text_config
|
49
50
|
@replacement_text_config ||= config['replacement_text']
|
50
51
|
end
|
52
|
+
|
53
|
+
def skipped_commit_types
|
54
|
+
@skipped_commit_types ||= config['skipped_commit_types'].map(&:to_sym)
|
55
|
+
end
|
51
56
|
end
|
52
57
|
end
|
@@ -129,12 +129,9 @@ module Overcommit
|
|
129
129
|
slots_released = processors_for_hook(hook)
|
130
130
|
@slots_available += slots_released
|
131
131
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
# useless signals
|
136
|
-
@resource.signal
|
137
|
-
end
|
132
|
+
# Signal every time in case there are threads that are already waiting for
|
133
|
+
# these slots to be released
|
134
|
+
@resource.signal
|
138
135
|
end
|
139
136
|
end
|
140
137
|
|
data/lib/overcommit/version.rb
CHANGED
metadata
CHANGED
@@ -1,35 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: overcommit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.49.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shane da Silva
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: childprocess
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0.6'
|
20
17
|
- - ">="
|
21
18
|
- !ruby/object:Gem::Version
|
22
19
|
version: 0.6.3
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '2.0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- - "~>"
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0.6'
|
30
27
|
- - ">="
|
31
28
|
- !ruby/object:Gem::Version
|
32
29
|
version: 0.6.3
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.0'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: iniparse
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -124,6 +124,7 @@ files:
|
|
124
124
|
- lib/overcommit/hook/pre_commit/chamber_compare.rb
|
125
125
|
- lib/overcommit/hook/pre_commit/chamber_security.rb
|
126
126
|
- lib/overcommit/hook/pre_commit/chamber_verification.rb
|
127
|
+
- lib/overcommit/hook/pre_commit/code_spell_check.rb
|
127
128
|
- lib/overcommit/hook/pre_commit/coffee_lint.rb
|
128
129
|
- lib/overcommit/hook/pre_commit/cook_style.rb
|
129
130
|
- lib/overcommit/hook/pre_commit/credo.rb
|
@@ -181,6 +182,7 @@ files:
|
|
181
182
|
- lib/overcommit/hook/pre_commit/rst_lint.rb
|
182
183
|
- lib/overcommit/hook/pre_commit/rubo_cop.rb
|
183
184
|
- lib/overcommit/hook/pre_commit/ruby_lint.rb
|
185
|
+
- lib/overcommit/hook/pre_commit/ruby_syntax.rb
|
184
186
|
- lib/overcommit/hook/pre_commit/scalariform.rb
|
185
187
|
- lib/overcommit/hook/pre_commit/scalastyle.rb
|
186
188
|
- lib/overcommit/hook/pre_commit/scss_lint.rb
|