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 +4 -4
- data/config/default.yml +53 -1
- data/lib/overcommit/git_repo.rb +14 -7
- data/lib/overcommit/hook/pre_commit/flay.rb +8 -0
- data/lib/overcommit/hook/pre_commit/herb_lint.rb +27 -0
- data/lib/overcommit/hook/pre_commit/solargraph.rb +1 -1
- data/lib/overcommit/utils.rb +25 -0
- data/lib/overcommit/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 887ad3a2999ba4744c926ad05bc61e453901822b378645d1dfbc10d4be0a0648
|
|
4
|
+
data.tar.gz: 66d06d2f6216a1e480c3e5ec053ea4fb967b6e8a80a7302d70a0cdd1a05207ef
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
data/lib/overcommit/git_repo.rb
CHANGED
|
@@ -160,7 +160,10 @@ module Overcommit
|
|
|
160
160
|
@merge_head = merge_head
|
|
161
161
|
end
|
|
162
162
|
|
|
163
|
-
|
|
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
|
-
|
|
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(
|
|
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(
|
|
195
|
-
f.write(
|
|
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(
|
|
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)
|
data/lib/overcommit/utils.rb
CHANGED
|
@@ -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.
|
data/lib/overcommit/version.rb
CHANGED
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.
|
|
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.
|
|
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.
|
|
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:
|
|
329
|
+
rubygems_version: 4.0.10
|
|
329
330
|
specification_version: 4
|
|
330
331
|
summary: Git hook manager
|
|
331
332
|
test_files: []
|