overcommit 0.67.1 → 0.69.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 +14 -0
- data/lib/overcommit/hook/pre_commit/scalastyle.rb +1 -1
- data/lib/overcommit/hook/pre_commit/solargraph.rb +48 -0
- data/lib/overcommit/utils.rb +6 -34
- data/lib/overcommit/version.rb +1 -1
- data/template-dir/hooks/commit-msg +0 -1
- data/template-dir/hooks/overcommit-hook +0 -1
- data/template-dir/hooks/post-checkout +0 -1
- data/template-dir/hooks/post-commit +0 -1
- data/template-dir/hooks/post-merge +0 -1
- data/template-dir/hooks/post-rewrite +0 -1
- data/template-dir/hooks/pre-commit +0 -1
- data/template-dir/hooks/pre-push +0 -1
- data/template-dir/hooks/pre-rebase +0 -1
- data/template-dir/hooks/prepare-commit-msg +0 -1
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3e487ccda9c90ec94450f359fa29f757077ca716801db2c86033d41c51e695c5
|
|
4
|
+
data.tar.gz: a61032840d8181959755fecfa98334903e4d2004ea0fb5b2f7f8b5981a4c2338
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 71d5ff6fb55f8936f94eda4a436cf5da48b9334d17c99f309759ccae0054ed4a7375e44a7885c9deebe7c5227737e61facf800c449e2fc4c6a1e5faf9b2f54c5
|
|
7
|
+
data.tar.gz: 0e8c1866c1cf004f5bd171cc59c31ba661b482a8e33e8febf43c6c4b12e60880c508546dc23f90b3f28357b64ddb9e73a582c9201e5edfd0d87b4688a3f5f342
|
data/config/default.yml
CHANGED
|
@@ -799,6 +799,20 @@ PreCommit:
|
|
|
799
799
|
install_command: 'gem install slim_lint'
|
|
800
800
|
include: '**/*.slim'
|
|
801
801
|
|
|
802
|
+
Solargraph:
|
|
803
|
+
enabled: false
|
|
804
|
+
description: 'Typecheck with Solargraph'
|
|
805
|
+
requires_files: true
|
|
806
|
+
required_executable: 'solargraph'
|
|
807
|
+
install_command: 'gem install solargraph'
|
|
808
|
+
flags: ['typecheck', '--level', 'strong']
|
|
809
|
+
include: '**/*.rb'
|
|
810
|
+
exclude:
|
|
811
|
+
- 'spec/**/*.rb'
|
|
812
|
+
- 'test/**/*.rb'
|
|
813
|
+
- 'vendor/**/*.rb'
|
|
814
|
+
- '.bundle/**/*.rb'
|
|
815
|
+
|
|
802
816
|
Sorbet:
|
|
803
817
|
enabled: false
|
|
804
818
|
description: 'Analyze with Sorbet'
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'overcommit'
|
|
4
|
+
require 'overcommit/hook/pre_commit/base'
|
|
5
|
+
|
|
6
|
+
module Overcommit
|
|
7
|
+
module Hook
|
|
8
|
+
module PreCommit
|
|
9
|
+
# Runs `solargraph typecheck` against any modified Ruby files.
|
|
10
|
+
#
|
|
11
|
+
# @see https://github.com/castwide/solargraph
|
|
12
|
+
class Solargraph < Base
|
|
13
|
+
MESSAGE_REGEX = /^\s*(?<file>(?:\w:)?[^:]+):(?<line>\d+) - /.freeze
|
|
14
|
+
|
|
15
|
+
def run
|
|
16
|
+
result = execute(command, args: applicable_files)
|
|
17
|
+
return :pass if result.success?
|
|
18
|
+
|
|
19
|
+
stderr_lines = remove_harmless_glitches(result.stderr)
|
|
20
|
+
violation_lines = result.stdout.split("\n").grep(MESSAGE_REGEX)
|
|
21
|
+
if violation_lines.empty?
|
|
22
|
+
if stderr_lines.empty?
|
|
23
|
+
[:fail, 'Solargraph failed to run']
|
|
24
|
+
else
|
|
25
|
+
# let's feed it stderr so users see the errors
|
|
26
|
+
extract_messages(stderr_lines, MESSAGE_REGEX)
|
|
27
|
+
end
|
|
28
|
+
else
|
|
29
|
+
extract_messages(violation_lines, MESSAGE_REGEX)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
private
|
|
34
|
+
|
|
35
|
+
# @param stderr [String]
|
|
36
|
+
#
|
|
37
|
+
# @return [Array<String>]
|
|
38
|
+
def remove_harmless_glitches(stderr)
|
|
39
|
+
stderr.split("\n").reject do |line|
|
|
40
|
+
line.include?('[WARN]') ||
|
|
41
|
+
line.include?('warning: parser/current is loading') ||
|
|
42
|
+
line.include?('Please see https://github.com/whitequark')
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
data/lib/overcommit/utils.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'etc'
|
|
3
4
|
require 'pathname'
|
|
4
5
|
require 'overcommit/os'
|
|
5
6
|
require 'overcommit/subprocess'
|
|
@@ -150,6 +151,9 @@ module Overcommit
|
|
|
150
151
|
else
|
|
151
152
|
`ps -ocommand= -p #{Process.ppid}`.chomp
|
|
152
153
|
end
|
|
154
|
+
rescue Errno::EPERM, Errno::ENOENT
|
|
155
|
+
# Process information may not be available, such as inside sandboxed environments
|
|
156
|
+
nil
|
|
153
157
|
end
|
|
154
158
|
|
|
155
159
|
# Execute a command in a subprocess, capturing exit status and output from
|
|
@@ -212,40 +216,8 @@ module Overcommit
|
|
|
212
216
|
end
|
|
213
217
|
|
|
214
218
|
# Return the number of processors used by the OS for process scheduling.
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
def processor_count # rubocop:disable all
|
|
218
|
-
@processor_count ||=
|
|
219
|
-
begin
|
|
220
|
-
if Overcommit::OS.windows?
|
|
221
|
-
require 'win32ole'
|
|
222
|
-
result = WIN32OLE.connect('winmgmts://').ExecQuery(
|
|
223
|
-
'select NumberOfLogicalProcessors from Win32_Processor'
|
|
224
|
-
)
|
|
225
|
-
result.to_enum.collect(&:NumberOfLogicalProcessors).reduce(:+)
|
|
226
|
-
elsif File.readable?('/proc/cpuinfo')
|
|
227
|
-
IO.read('/proc/cpuinfo').scan(/^processor/).size
|
|
228
|
-
elsif File.executable?('/usr/bin/hwprefs')
|
|
229
|
-
IO.popen('/usr/bin/hwprefs thread_count').read.to_i
|
|
230
|
-
elsif File.executable?('/usr/sbin/psrinfo')
|
|
231
|
-
IO.popen('/usr/sbin/psrinfo').read.scan(/^.*on-*line/).size
|
|
232
|
-
elsif File.executable?('/usr/sbin/ioscan')
|
|
233
|
-
IO.popen('/usr/sbin/ioscan -kC processor') do |out|
|
|
234
|
-
out.read.scan(/^.*processor/).size
|
|
235
|
-
end
|
|
236
|
-
elsif File.executable?('/usr/sbin/pmcycles')
|
|
237
|
-
IO.popen('/usr/sbin/pmcycles -m').read.count("\n")
|
|
238
|
-
elsif File.executable?('/usr/sbin/lsdev')
|
|
239
|
-
IO.popen('/usr/sbin/lsdev -Cc processor -S 1').read.count("\n")
|
|
240
|
-
elsif File.executable?('/usr/sbin/sysctl')
|
|
241
|
-
IO.popen('/usr/sbin/sysctl -n hw.ncpu').read.to_i
|
|
242
|
-
elsif File.executable?('/sbin/sysctl')
|
|
243
|
-
IO.popen('/sbin/sysctl -n hw.ncpu').read.to_i
|
|
244
|
-
else
|
|
245
|
-
# Unknown platform; assume 1 processor
|
|
246
|
-
1
|
|
247
|
-
end
|
|
248
|
-
end
|
|
219
|
+
def processor_count
|
|
220
|
+
@processor_count ||= Etc.nprocessors
|
|
249
221
|
end
|
|
250
222
|
|
|
251
223
|
# Calls a block of code with a modified set of environment variables,
|
data/lib/overcommit/version.rb
CHANGED
data/template-dir/hooks/pre-push
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: overcommit
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.69.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shane da Silva
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: childprocess
|
|
@@ -209,6 +209,7 @@ files:
|
|
|
209
209
|
- lib/overcommit/hook/pre_commit/semi_standard.rb
|
|
210
210
|
- lib/overcommit/hook/pre_commit/shell_check.rb
|
|
211
211
|
- lib/overcommit/hook/pre_commit/slim_lint.rb
|
|
212
|
+
- lib/overcommit/hook/pre_commit/solargraph.rb
|
|
212
213
|
- lib/overcommit/hook/pre_commit/sorbet.rb
|
|
213
214
|
- lib/overcommit/hook/pre_commit/sqlint.rb
|
|
214
215
|
- lib/overcommit/hook/pre_commit/standard.rb
|
|
@@ -322,7 +323,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
322
323
|
- !ruby/object:Gem::Version
|
|
323
324
|
version: '0'
|
|
324
325
|
requirements: []
|
|
325
|
-
rubygems_version: 3.6.
|
|
326
|
+
rubygems_version: 3.6.9
|
|
326
327
|
specification_version: 4
|
|
327
328
|
summary: Git hook manager
|
|
328
329
|
test_files: []
|