overcommit 0.62.0 → 0.63.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
  SHA256:
3
- metadata.gz: b862ff3b0a2650cafbdbc91fac3cda5ee83292ee0057e0446c954c555870ca76
4
- data.tar.gz: 50924c1e042458f471c130d17b9b3504938b6a8246d170c7a9eedcf24ed14424
3
+ metadata.gz: 5e9a2e23f1b830d2d9e8e500024cd01a1d368678b1f24039367ae88c90dc154a
4
+ data.tar.gz: 9c3fada758490c58d2341125315a988fe73fb9d4dc31c5167a400eddbff28846
5
5
  SHA512:
6
- metadata.gz: 872f9fb0720e7a5bebb76bf12faefcd7c8cd03927f1cf084d71115049edbe09ddc143d62f1c91548ea178ad9bd36a08685af3ea3bf552a6ab982cc5feac581e0
7
- data.tar.gz: 679b25b4f585a2031313798f422c6eb3ee07eff900dbb6d94a1d17f8bd62a474a1cde65a2acc51b310ae26dc55a0f0350b0e27a33029d5c7c64058b6b9ea62dd
6
+ metadata.gz: 2773a91d43bf69aa97c9f65fab59934502c2b948ad5264a7dd0def628d6d9bb21b78ebfd868b3a5e0c9457f609ede41fa11fdd1e92708dc27bb87fc433361b91
7
+ data.tar.gz: 79e8e222951cbaea5875fbd2bab3268d47ead4dde32fad029e76b46bd4823546d8beee1473b42df1575879c64a7ae7bdc7e8da2e970f4ec6766b5b85163409dc
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'
@@ -124,15 +124,13 @@ module Overcommit
124
124
  end
125
125
 
126
126
  @options[:targets].each do |target|
127
- begin
128
- Installer.new(log).run(target, @options)
129
- rescue Overcommit::Exceptions::InvalidGitRepo => e
130
- log.warning "Invalid repo #{target}: #{e}"
131
- halt 69 # EX_UNAVAILABLE
132
- rescue Overcommit::Exceptions::PreExistingHooks => e
133
- log.warning "Unable to install into #{target}: #{e}"
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
 
@@ -228,14 +228,12 @@ module Overcommit::Hook
228
228
  output = []
229
229
 
230
230
  required_libraries.each do |library|
231
- begin
232
- require library
233
- rescue LoadError
234
- install_command = @config['install_command']
235
- install_command = " -- install via #{install_command}" if install_command
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..-1].each_with_index do |line, index|
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"
@@ -12,7 +12,7 @@ module Overcommit::Hook::PreCommit
12
12
  return :pass if result.success?
13
13
 
14
14
  extract_messages(
15
- result.stdout.split("\n\n")[1..-1],
15
+ result.stdout.split("\n\n")[1..],
16
16
  MESSAGE_REGEX
17
17
  )
18
18
  end
@@ -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..-1].map { |msg| "#{file}: #{msg}" },
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
- begin
11
- JSON.parse(IO.read(file))
12
- rescue JSON::ParserError => e
13
- error = "#{e.message} parsing #{file}"
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,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'overcommit/hook/shared/r_spec'
4
+
5
+ module Overcommit::Hook::PreCommit
6
+ # Runs `rspec` test suite
7
+ #
8
+ # @see http://rspec.info/
9
+ class RSpec < Base
10
+ include Overcommit::Hook::Shared::RSpec
11
+ end
12
+ end
@@ -53,7 +53,7 @@ module Overcommit::Hook::PreCommit
53
53
  end
54
54
 
55
55
  def schema
56
- @schema ||= schema_files.map { |file| File.read(file, encoding) }.join
56
+ @schema ||= schema_files.map { |file| File.read(file, **(encoding || {})) }.join
57
57
  @schema.tr('_', '')
58
58
  end
59
59
 
@@ -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
- begin
11
- REXML::Document.new(IO.read(file))
12
- rescue REXML::ParseException => e
13
- error = "Error parsing #{file}: #{e.message}"
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, aliases: true)
12
- rescue ArgumentError
13
- begin
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 before push
6
+ # Runs `rspec` test suite
5
7
  #
6
8
  # @see http://rspec.info/
7
9
  class RSpec < Base
8
- def run
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..-1].join("\n")}"
29
+ "#{output_messages[index..].join("\n")}"
30
30
  end
31
31
 
32
32
  file = extract_file(match, message)
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Defines the gem version.
4
4
  module Overcommit
5
- VERSION = '0.62.0'
5
+ VERSION = '0.63.0'
6
6
  end
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.62.0
4
+ version: 0.63.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-01-16 00:00:00.000000000 Z
11
+ date: 2024-02-25 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
@@ -311,7 +314,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
311
314
  requirements:
312
315
  - - ">="
313
316
  - !ruby/object:Gem::Version
314
- version: '2.4'
317
+ version: '2.6'
315
318
  required_rubygems_version: !ruby/object:Gem::Requirement
316
319
  requirements:
317
320
  - - ">="