overcommit 0.68.0 → 0.70.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/ox_fmt.rb +35 -0
- data/lib/overcommit/hook/pre_commit/ox_lint.rb +35 -0
- data/lib/overcommit/utils.rb +6 -34
- data/lib/overcommit/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8040d08a9f79785e2cd046c2cf17996688fc0a83c81a9a21f0527501d3160b61
|
|
4
|
+
data.tar.gz: 7e2d8f6b3323dda0523a0f05994ad01e8321e652544ca3a71ffe746fa7e83b6d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: aa10fe74466654b81aca04252f85de4f7d34964250843a4908d7e3f6328ab63ec666e1cc9cd4c3d17a0aef63c2be4966a9f1a0ef1e2b3d25fd43beb33ecaa7fb
|
|
7
|
+
data.tar.gz: 64dbb9a221dcf7983923155f6bf461dd378b57969d0ac185856aa4fdc0908dd9c82b868f9f9db114712d5a4522ea74d9c4af5d255cd403ebdd181182ce440208
|
data/config/default.yml
CHANGED
|
@@ -565,6 +565,20 @@ PreCommit:
|
|
|
565
565
|
flags: ['-t']
|
|
566
566
|
include: '**/nginx.conf'
|
|
567
567
|
|
|
568
|
+
OxFmt:
|
|
569
|
+
enabled: false
|
|
570
|
+
description: 'Analyze with oxfmt'
|
|
571
|
+
required_executable: 'oxfmt'
|
|
572
|
+
flags: ['--check']
|
|
573
|
+
install_command: 'npm install -g oxfmt'
|
|
574
|
+
|
|
575
|
+
OxLint:
|
|
576
|
+
enabled: false
|
|
577
|
+
description: 'Analyze with oxlint'
|
|
578
|
+
required_executable: 'oxlint'
|
|
579
|
+
flags: ['--format=unix']
|
|
580
|
+
install_command: 'npm install -g oxlint'
|
|
581
|
+
|
|
568
582
|
Pep257: # Deprecated – use Pydocstyle instead.
|
|
569
583
|
enabled: false
|
|
570
584
|
description: 'Analyze docstrings with pep257'
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Overcommit::Hook::PreCommit
|
|
4
|
+
# Runs `oxfmt` against any modified files.
|
|
5
|
+
#
|
|
6
|
+
# Protip: if you have an npm script set up to run oxfmt, you can configure
|
|
7
|
+
# this hook to run oxfmt via your npm script by using the `command` option in
|
|
8
|
+
# your .overcommit.yml file. This can be useful if you have some oxfmt
|
|
9
|
+
# configuration built into your npm script that you don't want to repeat
|
|
10
|
+
# somewhere else. Example:
|
|
11
|
+
#
|
|
12
|
+
# oxfmt:
|
|
13
|
+
# required_executable: 'npm'
|
|
14
|
+
# enabled: true
|
|
15
|
+
# command: ['npm', 'run', 'fmt', '--', '--check']
|
|
16
|
+
#
|
|
17
|
+
# Note: This hook only supports check mode.
|
|
18
|
+
#
|
|
19
|
+
# @see https://oxc.rs
|
|
20
|
+
class OxFmt < Base
|
|
21
|
+
def run
|
|
22
|
+
oxfmt_regex = /^(?<file>.+) \(\d+ms\)/
|
|
23
|
+
result = execute(command, args: applicable_files)
|
|
24
|
+
output = result.stdout.chomp
|
|
25
|
+
messages = output.split("\n").grep(oxfmt_regex)
|
|
26
|
+
|
|
27
|
+
return [:fail, result.stderr] if messages.empty? && !result.success?
|
|
28
|
+
return :pass if result.success? && output.empty?
|
|
29
|
+
|
|
30
|
+
# example message:
|
|
31
|
+
# test.js (5ms)
|
|
32
|
+
extract_messages(messages, oxfmt_regex)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Overcommit::Hook::PreCommit
|
|
4
|
+
# Runs `oxlint` against any modified JavaScript files.
|
|
5
|
+
#
|
|
6
|
+
# Protip: if you have an npm script set up to run oxlint, you can configure
|
|
7
|
+
# this hook to run oxlint via your npm script by using the `command` option in
|
|
8
|
+
# your .overcommit.yml file. This can be useful if you have some oxlint
|
|
9
|
+
# configuration built into your npm script that you don't want to repeat
|
|
10
|
+
# somewhere else. Example:
|
|
11
|
+
#
|
|
12
|
+
# OxLint:
|
|
13
|
+
# required_executable: 'npm'
|
|
14
|
+
# enabled: true
|
|
15
|
+
# command: ['npm', 'run', 'lint', '--', '--format=unix']
|
|
16
|
+
#
|
|
17
|
+
# Note: This hook supports only unix format.
|
|
18
|
+
#
|
|
19
|
+
# @see https://oxc.rs
|
|
20
|
+
class OxLint < Base
|
|
21
|
+
def run
|
|
22
|
+
oxlint_regex = %r{^(?:file://)?(?<file>[^:]+):(?<line>\d+):\d+:.*?(?<type>Error|Warning)}
|
|
23
|
+
result = execute(command, args: applicable_files)
|
|
24
|
+
output = result.stdout.chomp
|
|
25
|
+
messages = output.split("\n").grep(oxlint_regex)
|
|
26
|
+
|
|
27
|
+
return [:fail, result.stderr] if messages.empty? && !result.success?
|
|
28
|
+
return :pass if result.success? && output.empty?
|
|
29
|
+
|
|
30
|
+
# example message:
|
|
31
|
+
# file://test.js:5:1: `debugger` statement is not allowed [Error/eslint(no-debugger)]
|
|
32
|
+
extract_messages(messages, oxlint_regex, lambda { |type| type.downcase.to_sym })
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
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
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.70.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
|
|
@@ -180,6 +180,8 @@ files:
|
|
|
180
180
|
- lib/overcommit/hook/pre_commit/merge_conflicts.rb
|
|
181
181
|
- lib/overcommit/hook/pre_commit/mix_format.rb
|
|
182
182
|
- lib/overcommit/hook/pre_commit/nginx_test.rb
|
|
183
|
+
- lib/overcommit/hook/pre_commit/ox_fmt.rb
|
|
184
|
+
- lib/overcommit/hook/pre_commit/ox_lint.rb
|
|
183
185
|
- lib/overcommit/hook/pre_commit/pep257.rb
|
|
184
186
|
- lib/overcommit/hook/pre_commit/pep8.rb
|
|
185
187
|
- lib/overcommit/hook/pre_commit/php_cs.rb
|
|
@@ -323,7 +325,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
323
325
|
- !ruby/object:Gem::Version
|
|
324
326
|
version: '0'
|
|
325
327
|
requirements: []
|
|
326
|
-
rubygems_version: 3.6.
|
|
328
|
+
rubygems_version: 3.6.9
|
|
327
329
|
specification_version: 4
|
|
328
330
|
summary: Git hook manager
|
|
329
331
|
test_files: []
|