overcommit 0.71.0 → 0.73.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: 5826d552313c4de8f5ee1f3f322e16d9193be5be215f4a1203deebd67e8b9333
4
- data.tar.gz: 1e013ca830726957ede05edefbeef7e2133851ea039bf819bdd0a22e506b94cb
3
+ metadata.gz: 887ad3a2999ba4744c926ad05bc61e453901822b378645d1dfbc10d4be0a0648
4
+ data.tar.gz: 66d06d2f6216a1e480c3e5ec053ea4fb967b6e8a80a7302d70a0cdd1a05207ef
5
5
  SHA512:
6
- metadata.gz: 7ba0463239dcab4fc78aa972f17d374e205e261ad86bf4eebcbdf4e7bc08af0b8b3b1b601276e25d98f9b22c2cf2835e87ca007cfad50dbe54bbdf996f311a56
7
- data.tar.gz: 3c5338c547754f27157ee427ac1c25eed520b036e91e8f901ea31919b5278a9dc99909d10268f8da54e27a1fcdb76fca8c7f1b10e419b0512a2b9eba5ea976e6
6
+ metadata.gz: 189138eaa9cf531fa861c87014ec420e9580c1d11f1492243050c542c32a8762e1f5d58ac82bdf18fc7526d257f0bb428192d9f8b6901c2b38a8717f0fd30a8a
7
+ data.tar.gz: 917260eb13fc2f85e828fbebdbd1f04c30c6acbaeb7e02b594452d35d8974dede978d8e882c41e35348e529e09d94e0ab54aa046087c9bbf80d62437eaf7e798
data/config/default.yml CHANGED
@@ -413,6 +413,12 @@ PreCommit:
413
413
  - '**/Makefile'
414
414
  - '**/*.go'
415
415
 
416
+ HerbLint:
417
+ enabled: false
418
+ description: 'Analyze with herb-lint'
419
+ required_executable: 'herb-lint'
420
+ include: '**/*.html.erb'
421
+
416
422
  Hlint:
417
423
  enabled: false
418
424
  description: 'Analyze with hlint'
@@ -569,8 +575,42 @@ PreCommit:
569
575
  enabled: false
570
576
  description: 'Analyze with oxfmt'
571
577
  required_executable: 'oxfmt'
572
- flags: ['--check']
578
+ flags: ['--check', '--no-error-on-unmatched-pattern']
573
579
  install_command: 'npm install -g oxfmt'
580
+ include:
581
+ - '**/*.js'
582
+ - '**/*.jsx'
583
+ - '**/*.mjs'
584
+ - '**/*.cjs'
585
+ - '**/*.ts'
586
+ - '**/*.tsx'
587
+ - '**/*.mts'
588
+ - '**/*.cts'
589
+ - '**/*.json'
590
+ - '**/*.jsonc'
591
+ - '**/*.json5'
592
+ - '**/*.css'
593
+ - '**/*.scss'
594
+ - '**/*.less'
595
+ - '**/*.pcss'
596
+ - '**/*.postcss'
597
+ - '**/*.graphql'
598
+ - '**/*.gql'
599
+ - '**/*.graphqls'
600
+ - '**/*.toml'
601
+ - '**/*.yml'
602
+ - '**/*.yaml'
603
+ - '**/*.html'
604
+ - '**/*.htm'
605
+ - '**/*.xhtml'
606
+ - '**/*.vue'
607
+ - '**/*.svelte'
608
+ - '**/*.md'
609
+ - '**/*.markdown'
610
+ - '**/*.mdx'
611
+ - '**/*.hbs'
612
+ - '**/*.handlebars'
613
+ - '**/*.mjml'
574
614
 
575
615
  OxLint:
576
616
  enabled: false
@@ -578,6 +618,18 @@ PreCommit:
578
618
  required_executable: 'oxlint'
579
619
  flags: ['--format=unix']
580
620
  install_command: 'npm install -g oxlint'
621
+ include:
622
+ - '**/*.js'
623
+ - '**/*.jsx'
624
+ - '**/*.mjs'
625
+ - '**/*.cjs'
626
+ - '**/*.ts'
627
+ - '**/*.tsx'
628
+ - '**/*.mts'
629
+ - '**/*.cts'
630
+ - '**/*.vue'
631
+ - '**/*.svelte'
632
+ - '**/*.astro'
581
633
 
582
634
  Pep257: # Deprecated – use Pydocstyle instead.
583
635
  enabled: false
@@ -160,7 +160,10 @@ module Overcommit
160
160
  @merge_head = merge_head
161
161
  end
162
162
 
163
- merge_msg_file = File.expand_path('MERGE_MSG', Overcommit::Utils.git_dir)
163
+ merge_mode_file = Overcommit::Utils.git_path('MERGE_MODE')
164
+ @merge_mode = File.open(merge_mode_file).read if File.exist?(merge_mode_file)
165
+
166
+ merge_msg_file = Overcommit::Utils.git_path('MERGE_MSG')
164
167
  @merge_msg = File.open(merge_msg_file).read if File.exist?(merge_msg_file)
165
168
  end
166
169
 
@@ -182,17 +185,22 @@ module Overcommit
182
185
  # of a merge.
183
186
  def restore_merge_state
184
187
  if @merge_head
185
- FileUtils.touch(File.expand_path('MERGE_MODE', Overcommit::Utils.git_dir))
188
+ if @merge_mode
189
+ File.open(Overcommit::Utils.git_path('MERGE_MODE'), 'w') do |f|
190
+ f.write(@merge_mode)
191
+ end
192
+ @merge_mode = nil
193
+ end
186
194
 
187
- File.open(File.expand_path('MERGE_HEAD', Overcommit::Utils.git_dir), 'w') do |f|
195
+ File.open(Overcommit::Utils.git_path('MERGE_HEAD'), 'w') do |f|
188
196
  f.write(@merge_head)
189
197
  end
190
198
  @merge_head = nil
191
199
  end
192
200
 
193
201
  if @merge_msg
194
- File.open(File.expand_path('MERGE_MSG', Overcommit::Utils.git_dir), 'w') do |f|
195
- f.write("#{@merge_msg}\n")
202
+ File.open(Overcommit::Utils.git_path('MERGE_MSG'), 'w') do |f|
203
+ f.write(@merge_msg)
196
204
  end
197
205
  @merge_msg = nil
198
206
  end
@@ -202,8 +210,7 @@ module Overcommit
202
210
  # of a cherry-pick.
203
211
  def restore_cherry_pick_state
204
212
  if @cherry_head
205
- File.open(File.expand_path('CHERRY_PICK_HEAD',
206
- Overcommit::Utils.git_dir), 'w') do |f|
213
+ File.open(Overcommit::Utils.git_path('CHERRY_PICK_HEAD'), 'w') do |f|
207
214
  f.write(@cherry_head)
208
215
  end
209
216
  @cherry_head = nil
@@ -24,6 +24,14 @@ module Overcommit::Hook::PreCommit
24
24
  # Run the command for each file
25
25
  applicable_files.each do |file|
26
26
  result = execute(command, args: [file])
27
+ # flay exits non-zero both when it finds duplication (with output on
28
+ # stdout) and when it crashes internally. A crash leaves stdout empty
29
+ # and writes a backtrace to stderr, so treat that as an error instead
30
+ # of silently passing.
31
+ if !result.success? && result.stdout.strip.empty?
32
+ return :fail, result.stderr
33
+ end
34
+
27
35
  results = result.stdout.split("\n\n")
28
36
  results.shift
29
37
  unless results.empty?
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Overcommit::Hook::PreCommit
4
+ # Runs `herb-lint` against any modified ERB files.
5
+ #
6
+ # @see https://herb-tools.dev/projects/linter
7
+ class HerbLint < Base
8
+ def run
9
+ result = execute(command + ['--json'], args: applicable_files)
10
+ return :pass if result.success?
11
+
12
+ json_output = JSON.parse(result.stdout)
13
+ json_output['offenses'].map do |offense|
14
+ severity = offense['severity'] == 'error' ? :error : :warning
15
+ filename = offense['filename']
16
+ line = offense['location']['start']['line']
17
+ message = offense['message']
18
+ code = offense['code']
19
+
20
+ Overcommit::Hook::Message.new(
21
+ severity, filename, line,
22
+ "#{filename}:#{line} #{code} #{message}"
23
+ )
24
+ end
25
+ end
26
+ end
27
+ end
@@ -10,7 +10,7 @@ module Overcommit
10
10
  #
11
11
  # @see https://github.com/castwide/solargraph
12
12
  class Solargraph < Base
13
- MESSAGE_REGEX = /^\s*(?<file>(?:\w:)?[^:]+):(?<line>\d+)( -|:) /.freeze
13
+ MESSAGE_REGEX = /^\s*(?<file>(?:\w:)?[^:]+):(?<line>\d+)(?: -|:) /.freeze
14
14
 
15
15
  def run
16
16
  result = execute(command, args: applicable_files)
@@ -74,6 +74,31 @@ module Overcommit
74
74
  end
75
75
  end
76
76
 
77
+ # Returns an absolute path to a file in the current worktree's Git
78
+ # directory.
79
+ #
80
+ # @param path [String]
81
+ # @return [String]
82
+ def git_path(path)
83
+ cmd = %w[git rev-parse]
84
+ if GIT_VERSION < '2.5'
85
+ cmd << '--git-dir'
86
+ else
87
+ cmd += ['--git-path', path]
88
+ end
89
+
90
+ result = execute(cmd)
91
+ unless result.success?
92
+ raise Overcommit::Exceptions::InvalidGitRepo,
93
+ 'Unable to determine Git path. ' \
94
+ 'Not a recognizable Git repository!'
95
+ end
96
+
97
+ resolved_path = result.stdout.chomp("\n")
98
+ resolved_path = File.join(resolved_path, path) if GIT_VERSION < '2.5'
99
+ File.expand_path(resolved_path, Dir.pwd)
100
+ end
101
+
77
102
  # Remove ANSI escape sequences from a string.
78
103
  #
79
104
  # This is useful for stripping colorized output from external tools.
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Defines the gem version.
4
4
  module Overcommit
5
- VERSION = '0.71.0'
5
+ VERSION = '0.73.0'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: overcommit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.71.0
4
+ version: 0.73.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane da Silva
@@ -49,14 +49,14 @@ dependencies:
49
49
  requirements:
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
- version: 3.3.9
52
+ version: 3.4.2
53
53
  type: :runtime
54
54
  prerelease: false
55
55
  version_requirements: !ruby/object:Gem::Requirement
56
56
  requirements:
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: 3.3.9
59
+ version: 3.4.2
60
60
  description: Utility to install, configure, and extend Git hooks
61
61
  email:
62
62
  - shane@dasilva.io
@@ -161,6 +161,7 @@ files:
161
161
  - lib/overcommit/hook/pre_commit/hadolint.rb
162
162
  - lib/overcommit/hook/pre_commit/haml_lint.rb
163
163
  - lib/overcommit/hook/pre_commit/hard_tabs.rb
164
+ - lib/overcommit/hook/pre_commit/herb_lint.rb
164
165
  - lib/overcommit/hook/pre_commit/hlint.rb
165
166
  - lib/overcommit/hook/pre_commit/html_hint.rb
166
167
  - lib/overcommit/hook/pre_commit/html_tidy.rb
@@ -325,7 +326,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
325
326
  - !ruby/object:Gem::Version
326
327
  version: '0'
327
328
  requirements: []
328
- rubygems_version: 3.6.9
329
+ rubygems_version: 4.0.10
329
330
  specification_version: 4
330
331
  summary: Git hook manager
331
332
  test_files: []