overcommit 0.57.0 → 0.58.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 +20 -0
- data/lib/overcommit/configuration_loader.rb +8 -5
- data/lib/overcommit/hook/pre_commit/dart_analyzer.rb +22 -0
- data/lib/overcommit/hook/pre_commit/es_lint.rb +3 -6
- data/lib/overcommit/hook/pre_commit/yaml_lint.rb +25 -4
- data/lib/overcommit/hook/pre_push/flutter_test.rb +16 -0
- data/lib/overcommit/hook/pre_push/pub_test.rb +16 -0
- data/lib/overcommit/hook_context/helpers/stash_unstaged_changes.rb +1 -1
- data/lib/overcommit/version.rb +1 -1
- data/libexec/index-tags +6 -4
- metadata +22 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0d6feac2b1b10b983db054fa8931f302ff8eb8105c6d8788ad965ce986c990c
|
4
|
+
data.tar.gz: bf03cf18734e6139e5d7885ea1dcffb5d2aa0dcbad07ac8ec4d3cceff53d62e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 915b83736de391fe61565da7bd5caca5bf427cca3bf8f6f6aa4d6a639bf151e55d3fc61578b06eab6ffda215abe8e77e209b34d95a0ad4f6988b66fea4773a67
|
7
|
+
data.tar.gz: 445041c3c00b3d5cfa34c65aae868459f515c24ed4bc40017dd6bfdb91a3a6060c305a24eb03537a3ab0be401241f480fe12c42f3b70cf8fb6835f2d65f8dc6c
|
data/config/default.yml
CHANGED
@@ -266,6 +266,14 @@ PreCommit:
|
|
266
266
|
install_command: 'npm install -g csslint'
|
267
267
|
include: '**/*.css'
|
268
268
|
|
269
|
+
DartAnalyzer:
|
270
|
+
enabled: false
|
271
|
+
description: 'Analyze with dartanalyzer'
|
272
|
+
required_executable: 'dartanalyzer'
|
273
|
+
flags: []
|
274
|
+
include:
|
275
|
+
- '**/*.dart'
|
276
|
+
|
269
277
|
Dogma:
|
270
278
|
enabled: false
|
271
279
|
description: 'Analyze with dogma'
|
@@ -1276,6 +1284,12 @@ PrePush:
|
|
1276
1284
|
flags: ['test']
|
1277
1285
|
include: 'src/**/*.rs'
|
1278
1286
|
|
1287
|
+
FlutterTest:
|
1288
|
+
enabled: false
|
1289
|
+
description: 'Run flutter test suite'
|
1290
|
+
required_executable: 'flutter'
|
1291
|
+
flags: ['test']
|
1292
|
+
|
1279
1293
|
GitLfs:
|
1280
1294
|
enabled: false
|
1281
1295
|
description: 'Upload files tracked by Git LFS'
|
@@ -1322,6 +1336,12 @@ PrePush:
|
|
1322
1336
|
destructive_only: true
|
1323
1337
|
branches: ['master']
|
1324
1338
|
|
1339
|
+
PubTest:
|
1340
|
+
enabled: false
|
1341
|
+
description: 'Run pub test suite'
|
1342
|
+
required_executable: 'pub'
|
1343
|
+
flags: ['run', 'test']
|
1344
|
+
|
1325
1345
|
Pytest:
|
1326
1346
|
enabled: false
|
1327
1347
|
description: 'Run pytest test suite'
|
@@ -24,13 +24,16 @@ module Overcommit
|
|
24
24
|
# @option logger [Overcommit::Logger]
|
25
25
|
# @return [Overcommit::Configuration]
|
26
26
|
def load_from_file(file, options = {})
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
# Psych 4 introduced breaking behavior that doesn't support aliases by
|
28
|
+
# default. Explicitly enable aliases if the option is available.
|
29
|
+
yaml =
|
30
|
+
begin
|
31
|
+
YAML.load_file(file, aliases: true)
|
32
|
+
rescue ArgumentError
|
33
|
+
YAML.load_file(file)
|
32
34
|
end
|
33
35
|
|
36
|
+
hash = yaml ? yaml.to_hash : {}
|
34
37
|
Overcommit::Configuration.new(hash, options)
|
35
38
|
end
|
36
39
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Overcommit::Hook::PreCommit
|
4
|
+
# Runs `dartanalyzer` against modified Dart files.
|
5
|
+
# @see https://dart.dev/tools/dartanalyzer
|
6
|
+
class DartAnalyzer < Base
|
7
|
+
MESSAGE_REGEX = /(?<type>.*)•\ (?<message>[^•]+)•\ (?<file>[^:]+):(?<line>\d+):(\d+)\.*/
|
8
|
+
|
9
|
+
def run
|
10
|
+
result = execute(command, args: applicable_files)
|
11
|
+
return :pass if result.success?
|
12
|
+
|
13
|
+
extract_messages(
|
14
|
+
result.stdout.split("\n").grep(MESSAGE_REGEX),
|
15
|
+
MESSAGE_REGEX,
|
16
|
+
lambda do |type|
|
17
|
+
type.include?('error') ? :error : :warning
|
18
|
+
end
|
19
|
+
)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -19,20 +19,17 @@ module Overcommit::Hook::PreCommit
|
|
19
19
|
# @see http://eslint.org/
|
20
20
|
class EsLint < Base
|
21
21
|
def run
|
22
|
+
eslint_regex = /^(?<file>[^\s](?:\w:)?[^:]+):[^\d]+(?<line>\d+).*?(?<type>Error|Warning)/
|
22
23
|
result = execute(command, args: applicable_files)
|
23
24
|
output = result.stdout.chomp
|
24
|
-
messages = output.split("\n").grep(
|
25
|
+
messages = output.split("\n").grep(eslint_regex)
|
25
26
|
|
26
27
|
return [:fail, result.stderr] if messages.empty? && !result.success?
|
27
28
|
return :pass if result.success? && output.empty?
|
28
29
|
|
29
30
|
# example message:
|
30
31
|
# path/to/file.js: line 1, col 0, Error - Error message (ruleName)
|
31
|
-
extract_messages(
|
32
|
-
messages,
|
33
|
-
/^(?<file>(?:\w:)?[^:]+):[^\d]+(?<line>\d+).*?(?<type>Error|Warning)/,
|
34
|
-
lambda { |type| type.downcase.to_sym }
|
35
|
-
)
|
32
|
+
extract_messages(messages, eslint_regex, lambda { |type| type.downcase.to_sym })
|
36
33
|
end
|
37
34
|
end
|
38
35
|
end
|
@@ -5,13 +5,34 @@ module Overcommit::Hook::PreCommit
|
|
5
5
|
#
|
6
6
|
# @see https://github.com/adrienverge/yamllint
|
7
7
|
class YamlLint < Base
|
8
|
+
MESSAGE_REGEX = /
|
9
|
+
^(?<file>.+)
|
10
|
+
:(?<line>\d+)
|
11
|
+
:(?<col>\d+)
|
12
|
+
:\s\[(?<type>\w+)\]
|
13
|
+
\s(?<msg>.+)$
|
14
|
+
/x
|
15
|
+
|
8
16
|
def run
|
9
17
|
result = execute(command, args: applicable_files)
|
18
|
+
parse_messages(result.stdout)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def parse_messages(output)
|
24
|
+
repo_root = Overcommit::Utils.repo_root
|
25
|
+
|
26
|
+
output.scan(MESSAGE_REGEX).map do |file, line, col, type, msg|
|
27
|
+
line = line.to_i
|
28
|
+
type = type.to_sym
|
29
|
+
# Obtain the path relative to the root of the repository
|
30
|
+
# for nicer output:
|
31
|
+
relpath = file.dup
|
32
|
+
relpath.slice!("#{repo_root}/")
|
10
33
|
|
11
|
-
|
12
|
-
|
13
|
-
else
|
14
|
-
return [:warn, result.stdout]
|
34
|
+
text = "#{relpath}:#{line}:#{col}:#{type} #{msg}"
|
35
|
+
Overcommit::Hook::Message.new(type, file, line, text)
|
15
36
|
end
|
16
37
|
end
|
17
38
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Overcommit::Hook::PrePush
|
4
|
+
# Runs Flutter test suite (`flutter test`) before push
|
5
|
+
#
|
6
|
+
# @see https://api.flutter.dev/flutter/flutter_test/flutter_test-library.html
|
7
|
+
class FlutterTest < Base
|
8
|
+
def run
|
9
|
+
result = execute(command)
|
10
|
+
return :pass if result.success?
|
11
|
+
|
12
|
+
output = result.stdout + result.stderr
|
13
|
+
[:fail, output]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Overcommit::Hook::PrePush
|
4
|
+
# Runs Dart test suite (`pub run test`) before push
|
5
|
+
#
|
6
|
+
# @see https://pub.dev/packages/test#running-tests
|
7
|
+
class PubTest < Base
|
8
|
+
def run
|
9
|
+
result = execute(command)
|
10
|
+
return :pass if result.success?
|
11
|
+
|
12
|
+
output = result.stdout + result.stderr
|
13
|
+
[:fail, output]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -129,7 +129,7 @@ module Overcommit::HookContext
|
|
129
129
|
|
130
130
|
# Applies the stash to the working tree to restore the user's state.
|
131
131
|
def restore_working_tree
|
132
|
-
result = Overcommit::Utils.execute(%w[git stash pop --index
|
132
|
+
result = Overcommit::Utils.execute(%w[git stash pop --index])
|
133
133
|
unless result.success?
|
134
134
|
raise Overcommit::Exceptions::HookCleanupFailed,
|
135
135
|
"Unable to restore working tree after #{hook_script_name} hooks run:" \
|
data/lib/overcommit/version.rb
CHANGED
data/libexec/index-tags
CHANGED
@@ -6,10 +6,12 @@
|
|
6
6
|
|
7
7
|
set -e
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
dir="`git rev-parse --git-dir`"
|
10
|
+
|
11
|
+
trap "rm -f $dir/tags.$$" EXIT
|
12
|
+
err_file=$dir/ctags.err
|
13
|
+
if ctags --tag-relative -Rf$dir/tags.$$ --exclude=.git "$@" 2>${err_file}; then
|
14
|
+
mv $dir/tags.$$ $dir/tags
|
13
15
|
[ -e ${err_file} ] && rm -f ${err_file}
|
14
16
|
else
|
15
17
|
# Ignore STDERR unless `ctags` returned a non-zero exit code
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: overcommit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.58.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shane da Silva
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: childprocess
|
@@ -44,6 +44,20 @@ dependencies:
|
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '1.4'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rexml
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '3.2'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '3.2'
|
47
61
|
description: Utility to install, configure, and extend Git hooks
|
48
62
|
email:
|
49
63
|
- shane@dasilva.io
|
@@ -129,6 +143,7 @@ files:
|
|
129
143
|
- lib/overcommit/hook/pre_commit/cook_style.rb
|
130
144
|
- lib/overcommit/hook/pre_commit/credo.rb
|
131
145
|
- lib/overcommit/hook/pre_commit/css_lint.rb
|
146
|
+
- lib/overcommit/hook/pre_commit/dart_analyzer.rb
|
132
147
|
- lib/overcommit/hook/pre_commit/dogma.rb
|
133
148
|
- lib/overcommit/hook/pre_commit/erb_lint.rb
|
134
149
|
- lib/overcommit/hook/pre_commit/es_lint.rb
|
@@ -213,12 +228,14 @@ files:
|
|
213
228
|
- lib/overcommit/hook/pre_push/base.rb
|
214
229
|
- lib/overcommit/hook/pre_push/brakeman.rb
|
215
230
|
- lib/overcommit/hook/pre_push/cargo_test.rb
|
231
|
+
- lib/overcommit/hook/pre_push/flutter_test.rb
|
216
232
|
- lib/overcommit/hook/pre_push/go_test.rb
|
217
233
|
- lib/overcommit/hook/pre_push/golangci_lint.rb
|
218
234
|
- lib/overcommit/hook/pre_push/minitest.rb
|
219
235
|
- lib/overcommit/hook/pre_push/php_unit.rb
|
220
236
|
- lib/overcommit/hook/pre_push/pronto.rb
|
221
237
|
- lib/overcommit/hook/pre_push/protected_branches.rb
|
238
|
+
- lib/overcommit/hook/pre_push/pub_test.rb
|
222
239
|
- lib/overcommit/hook/pre_push/pytest.rb
|
223
240
|
- lib/overcommit/hook/pre_push/python_nose.rb
|
224
241
|
- lib/overcommit/hook/pre_push/r_spec.rb
|
@@ -299,8 +316,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
299
316
|
- !ruby/object:Gem::Version
|
300
317
|
version: '0'
|
301
318
|
requirements: []
|
302
|
-
rubygems_version: 3.1.
|
303
|
-
signing_key:
|
319
|
+
rubygems_version: 3.1.4
|
320
|
+
signing_key:
|
304
321
|
specification_version: 4
|
305
322
|
summary: Git hook manager
|
306
323
|
test_files: []
|