overcommit 0.62.0 → 0.64.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 +13 -0
- data/lib/overcommit/cli.rb +7 -9
- data/lib/overcommit/hook/base.rb +6 -8
- data/lib/overcommit/hook/commit_msg/text_width.rb +1 -1
- data/lib/overcommit/hook/pre_commit/erb_lint.rb +1 -1
- data/lib/overcommit/hook/pre_commit/html_hint.rb +1 -1
- data/lib/overcommit/hook/pre_commit/json_syntax.rb +4 -6
- data/lib/overcommit/hook/pre_commit/r_spec.rb +12 -0
- data/lib/overcommit/hook/pre_commit/rails_schema_up_to_date.rb +1 -1
- data/lib/overcommit/hook/pre_commit/sorbet.rb +24 -0
- data/lib/overcommit/hook/pre_commit/stylelint.rb +1 -1
- data/lib/overcommit/hook/pre_commit/xml_syntax.rb +4 -6
- data/lib/overcommit/hook/pre_commit/yaml_syntax.rb +7 -9
- data/lib/overcommit/hook/pre_push/r_spec.rb +4 -8
- data/lib/overcommit/hook/shared/r_spec.rb +21 -0
- data/lib/overcommit/utils/messages_utils.rb +1 -1
- data/lib/overcommit/version.rb +1 -1
- metadata +9 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d85e2036f46d697b370c4926beb8f858a92ebc106590724e02eadef769c532b9
|
4
|
+
data.tar.gz: bc5686ac420e3ecee206e8921ee02f103852fb918e9fcf84f1a9c9cb576debe9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a112cadfb48618428bbe1763561fe080f9968b853a7132c7c382276dd94557c6ea1ee3ed28b4e8fafd6e000e80d4e385a6bc81de586ea829e66cf0754deae43f
|
7
|
+
data.tar.gz: 7a237d6149d73b60b72113eaf31bcad7d967d9b2c330a2229fb90d795caaaeebf94fac8113660dd0468c6062dfc957c1134fbfec18385c68f61858bebabf1852
|
data/config/default.yml
CHANGED
@@ -709,6 +709,11 @@ PreCommit:
|
|
709
709
|
install_command: 'pip install restructuredtext_lint'
|
710
710
|
include: '**/*.rst'
|
711
711
|
|
712
|
+
RSpec:
|
713
|
+
enabled: false
|
714
|
+
description: 'Run tests with Rspec'
|
715
|
+
required_executable: 'rspec'
|
716
|
+
|
712
717
|
RuboCop:
|
713
718
|
enabled: false
|
714
719
|
description: 'Analyze with RuboCop'
|
@@ -790,6 +795,14 @@ PreCommit:
|
|
790
795
|
install_command: 'gem install slim_lint'
|
791
796
|
include: '**/*.slim'
|
792
797
|
|
798
|
+
Sorbet:
|
799
|
+
enabled: false
|
800
|
+
description: 'Analyze with Sorbet'
|
801
|
+
required_executable: 'srb'
|
802
|
+
install_command: 'gem install sorbet'
|
803
|
+
command: ['srb', 'tc']
|
804
|
+
include: '**/*.rb'
|
805
|
+
|
793
806
|
Sqlint:
|
794
807
|
enabled: false
|
795
808
|
description: 'Analyze with sqlint'
|
data/lib/overcommit/cli.rb
CHANGED
@@ -124,15 +124,13 @@ module Overcommit
|
|
124
124
|
end
|
125
125
|
|
126
126
|
@options[:targets].each do |target|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
halt 73 # EX_CANTCREAT
|
135
|
-
end
|
127
|
+
Installer.new(log).run(target, @options)
|
128
|
+
rescue Overcommit::Exceptions::InvalidGitRepo => e
|
129
|
+
log.warning "Invalid repo #{target}: #{e}"
|
130
|
+
halt 69 # EX_UNAVAILABLE
|
131
|
+
rescue Overcommit::Exceptions::PreExistingHooks => e
|
132
|
+
log.warning "Unable to install into #{target}: #{e}"
|
133
|
+
halt 73 # EX_CANTCREAT
|
136
134
|
end
|
137
135
|
end
|
138
136
|
|
data/lib/overcommit/hook/base.rb
CHANGED
@@ -228,14 +228,12 @@ module Overcommit::Hook
|
|
228
228
|
output = []
|
229
229
|
|
230
230
|
required_libraries.each do |library|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
output << "Unable to load '#{library}'#{install_command}"
|
238
|
-
end
|
231
|
+
require library
|
232
|
+
rescue LoadError
|
233
|
+
install_command = @config['install_command']
|
234
|
+
install_command = " -- install via #{install_command}" if install_command
|
235
|
+
|
236
|
+
output << "Unable to load '#{library}'#{install_command}"
|
239
237
|
end
|
240
238
|
|
241
239
|
return if output.empty?
|
@@ -41,7 +41,7 @@ module Overcommit::Hook::CommitMsg
|
|
41
41
|
|
42
42
|
max_body_width = config['max_body_width']
|
43
43
|
|
44
|
-
lines[2
|
44
|
+
lines[2..].each_with_index do |line, index|
|
45
45
|
if line.chomp.size > max_body_width
|
46
46
|
@errors << "Line #{index + 3} of commit message has > " \
|
47
47
|
"#{max_body_width} characters"
|
@@ -14,7 +14,7 @@ module Overcommit::Hook::PreCommit
|
|
14
14
|
lines = group.split("\n").map(&:strip)
|
15
15
|
file = lines[0][/(.+):/, 1]
|
16
16
|
extract_messages(
|
17
|
-
lines[1
|
17
|
+
lines[1..].map { |msg| "#{file}: #{msg}" },
|
18
18
|
/^(?<file>(?:\w:)?[^:]+): line (?<line>\d+)/
|
19
19
|
)
|
20
20
|
end.flatten
|
@@ -7,12 +7,10 @@ module Overcommit::Hook::PreCommit
|
|
7
7
|
messages = []
|
8
8
|
|
9
9
|
applicable_files.each do |file|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
messages << Overcommit::Hook::Message.new(:error, file, nil, error)
|
15
|
-
end
|
10
|
+
JSON.parse(IO.read(file))
|
11
|
+
rescue JSON::ParserError => e
|
12
|
+
error = "#{e.message} parsing #{file}"
|
13
|
+
messages << Overcommit::Hook::Message.new(:error, file, nil, error)
|
16
14
|
end
|
17
15
|
|
18
16
|
messages
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Overcommit::Hook::PreCommit
|
4
|
+
# Runs 'srb tc' against any modified files.
|
5
|
+
#
|
6
|
+
# @see https://github.com/sorbet/sorbet
|
7
|
+
class Sorbet < Base
|
8
|
+
# example of output:
|
9
|
+
# sorbet.rb:1: Method `foo` does not exist on `T.class_of(Bar)` https://srb.help/7003
|
10
|
+
MESSAGE_REGEX = /^(?<file>[^:]+):(?<line>\d+): (?<message>.*)$/.freeze
|
11
|
+
|
12
|
+
def run
|
13
|
+
result = execute(command, args: applicable_files)
|
14
|
+
return :pass if result.success?
|
15
|
+
|
16
|
+
output = result.stderr.split("\n").grep(MESSAGE_REGEX)
|
17
|
+
|
18
|
+
extract_messages(
|
19
|
+
output,
|
20
|
+
MESSAGE_REGEX
|
21
|
+
)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -7,12 +7,10 @@ module Overcommit::Hook::PreCommit
|
|
7
7
|
messages = []
|
8
8
|
|
9
9
|
applicable_files.each do |file|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
messages << Overcommit::Hook::Message.new(:error, file, nil, error)
|
15
|
-
end
|
10
|
+
REXML::Document.new(IO.read(file))
|
11
|
+
rescue REXML::ParseException => e
|
12
|
+
error = "Error parsing #{file}: #{e.message}"
|
13
|
+
messages << Overcommit::Hook::Message.new(:error, file, nil, error)
|
16
14
|
end
|
17
15
|
|
18
16
|
messages
|
@@ -7,17 +7,15 @@ module Overcommit::Hook::PreCommit
|
|
7
7
|
messages = []
|
8
8
|
|
9
9
|
applicable_files.each do |file|
|
10
|
+
YAML.load_file(file, aliases: true)
|
11
|
+
rescue ArgumentError
|
10
12
|
begin
|
11
|
-
YAML.load_file(file
|
12
|
-
rescue ArgumentError
|
13
|
-
|
14
|
-
YAML.load_file(file)
|
15
|
-
rescue ArgumentError, Psych::SyntaxError => e
|
16
|
-
messages << Overcommit::Hook::Message.new(:error, file, nil, e.message)
|
17
|
-
end
|
18
|
-
rescue Psych::DisallowedClass => e
|
19
|
-
messages << error_message(file, e)
|
13
|
+
YAML.load_file(file)
|
14
|
+
rescue ArgumentError, Psych::SyntaxError => e
|
15
|
+
messages << Overcommit::Hook::Message.new(:error, file, nil, e.message)
|
20
16
|
end
|
17
|
+
rescue Psych::DisallowedClass => e
|
18
|
+
messages << error_message(file, e)
|
21
19
|
end
|
22
20
|
|
23
21
|
messages
|
@@ -1,16 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'overcommit/hook/shared/r_spec'
|
4
|
+
|
3
5
|
module Overcommit::Hook::PrePush
|
4
|
-
# Runs `rspec` test suite
|
6
|
+
# Runs `rspec` test suite
|
5
7
|
#
|
6
8
|
# @see http://rspec.info/
|
7
9
|
class RSpec < Base
|
8
|
-
|
9
|
-
result = execute(command)
|
10
|
-
return :pass if result.success?
|
11
|
-
|
12
|
-
output = result.stdout + result.stderr
|
13
|
-
[:fail, output]
|
14
|
-
end
|
10
|
+
include Overcommit::Hook::Shared::RSpec
|
15
11
|
end
|
16
12
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Overcommit::Hook::Shared
|
4
|
+
# Runs `rspec` test suite before push
|
5
|
+
#
|
6
|
+
# @see http://rspec.info/
|
7
|
+
module RSpec
|
8
|
+
def run
|
9
|
+
result = if @config['include']
|
10
|
+
execute(command, args: applicable_files)
|
11
|
+
else
|
12
|
+
execute(command)
|
13
|
+
end
|
14
|
+
|
15
|
+
return :pass if result.success?
|
16
|
+
|
17
|
+
output = result.stdout + result.stderr
|
18
|
+
[:fail, output]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -26,7 +26,7 @@ module Overcommit::Utils
|
|
26
26
|
raise Overcommit::Exceptions::MessageProcessingError,
|
27
27
|
'Unexpected output: unable to determine line number or type ' \
|
28
28
|
"of error/warning for output:\n" \
|
29
|
-
"#{output_messages[index
|
29
|
+
"#{output_messages[index..].join("\n")}"
|
30
30
|
end
|
31
31
|
|
32
32
|
file = extract_file(match, message)
|
data/lib/overcommit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: overcommit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.64.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: 2024-
|
11
|
+
date: 2024-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: childprocess
|
@@ -195,6 +195,7 @@ files:
|
|
195
195
|
- lib/overcommit/hook/pre_commit/pyflakes.rb
|
196
196
|
- lib/overcommit/hook/pre_commit/pylint.rb
|
197
197
|
- lib/overcommit/hook/pre_commit/python_flake8.rb
|
198
|
+
- lib/overcommit/hook/pre_commit/r_spec.rb
|
198
199
|
- lib/overcommit/hook/pre_commit/rails_best_practices.rb
|
199
200
|
- lib/overcommit/hook/pre_commit/rails_schema_up_to_date.rb
|
200
201
|
- lib/overcommit/hook/pre_commit/rake_target.rb
|
@@ -209,6 +210,7 @@ files:
|
|
209
210
|
- lib/overcommit/hook/pre_commit/semi_standard.rb
|
210
211
|
- lib/overcommit/hook/pre_commit/shell_check.rb
|
211
212
|
- lib/overcommit/hook/pre_commit/slim_lint.rb
|
213
|
+
- lib/overcommit/hook/pre_commit/sorbet.rb
|
212
214
|
- lib/overcommit/hook/pre_commit/sqlint.rb
|
213
215
|
- lib/overcommit/hook/pre_commit/standard.rb
|
214
216
|
- lib/overcommit/hook/pre_commit/stylelint.rb
|
@@ -253,6 +255,7 @@ files:
|
|
253
255
|
- lib/overcommit/hook/shared/index_tags.rb
|
254
256
|
- lib/overcommit/hook/shared/npm_install.rb
|
255
257
|
- lib/overcommit/hook/shared/pronto.rb
|
258
|
+
- lib/overcommit/hook/shared/r_spec.rb
|
256
259
|
- lib/overcommit/hook/shared/rake_target.rb
|
257
260
|
- lib/overcommit/hook/shared/submodule_status.rb
|
258
261
|
- lib/overcommit/hook/shared/yarn_install.rb
|
@@ -301,7 +304,8 @@ files:
|
|
301
304
|
homepage: https://github.com/sds/overcommit
|
302
305
|
licenses:
|
303
306
|
- MIT
|
304
|
-
metadata:
|
307
|
+
metadata:
|
308
|
+
changelog_uri: https://github.com/sds/overcommit/blob/main/CHANGELOG.md
|
305
309
|
post_install_message: Install hooks by running `overcommit --install` in your Git
|
306
310
|
repository
|
307
311
|
rdoc_options: []
|
@@ -311,14 +315,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
311
315
|
requirements:
|
312
316
|
- - ">="
|
313
317
|
- !ruby/object:Gem::Version
|
314
|
-
version: '2.
|
318
|
+
version: '2.6'
|
315
319
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
316
320
|
requirements:
|
317
321
|
- - ">="
|
318
322
|
- !ruby/object:Gem::Version
|
319
323
|
version: '0'
|
320
324
|
requirements: []
|
321
|
-
rubygems_version: 3.
|
325
|
+
rubygems_version: 3.5.9
|
322
326
|
signing_key:
|
323
327
|
specification_version: 4
|
324
328
|
summary: Git hook manager
|