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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 57b026be0de6f8992a7959d366a7c131025b1de64e442d5fdbf3e73481501645
4
- data.tar.gz: 17e3e01c75287dcfac05d6e8b8114db2aa772cd407efed388bd68674714ff46c
3
+ metadata.gz: 8040d08a9f79785e2cd046c2cf17996688fc0a83c81a9a21f0527501d3160b61
4
+ data.tar.gz: 7e2d8f6b3323dda0523a0f05994ad01e8321e652544ca3a71ffe746fa7e83b6d
5
5
  SHA512:
6
- metadata.gz: 6a0f34b82082e8b20eb23c7cb77066d2a2f6135d38b8a700c247f014100c2bd6f4ab6f0e0ff14517e219891eafa54a4d0bf4796604971d91d5125e2435d17e11
7
- data.tar.gz: a7f96cef415b1722d62f4cede3af1808005c16f892095ea1ff7f420eef00bd448dad778fc699c5e4360dab1f21847cd892375187c2a6ad8ef1d14944573a5d1a
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
@@ -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
- # @see https://github.com/grosser/parallel/blob/v1.6.1/lib/parallel/processor_count.rb#L17-L51
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,
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Defines the gem version.
4
4
  module Overcommit
5
- VERSION = '0.68.0'
5
+ VERSION = '0.70.0'
6
6
  end
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.68.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: 2025-06-30 00:00:00.000000000 Z
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.2
328
+ rubygems_version: 3.6.9
327
329
  specification_version: 4
328
330
  summary: Git hook manager
329
331
  test_files: []