overcommit 0.59.0 → 0.60.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 +17 -1
- data/lib/overcommit/configuration_loader.rb +12 -4
- data/lib/overcommit/constants.rb +1 -0
- data/lib/overcommit/hook/pre_commit/bundle_check.rb +1 -1
- data/lib/overcommit/hook/pre_commit/mix_format.rb +30 -0
- data/lib/overcommit/hook/pre_commit/rails_schema_up_to_date.rb +7 -1
- data/lib/overcommit/hook/pre_commit/yaml_syntax.rb +9 -0
- data/lib/overcommit/hook/pre_push/mix_test.rb +16 -0
- data/lib/overcommit/hook/prepare_commit_msg/replace_branch.rb +4 -4
- data/lib/overcommit/subprocess.rb +1 -22
- data/lib/overcommit/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f9628c356de69c116c7a315732abfe802f91578cbcf2665c450ec7bfeddfd297
|
|
4
|
+
data.tar.gz: b0f5f78774b47295f7200ea994a1dfa9d05eb9155d57f31a2f95ee7a60ed6d1f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9b6a07c9a752bb5ce51f432b51c43f4f225ba2891806ca1deb1ac8e77134ad4ebfa26dbb5050393f9d4529fc1a9df18fee84f4c59dc418a534002dd817bae90e
|
|
7
|
+
data.tar.gz: 24b3f6be4e83a9e7167d7f66d5d2179be00777aa5209bfce778fc33b297a57ad045164421a9d46f8c66ffb6c2274af556dcbd87d0b2fecfe3000024c23eeb673
|
data/config/default.yml
CHANGED
|
@@ -536,6 +536,16 @@ PreCommit:
|
|
|
536
536
|
required_executable: 'grep'
|
|
537
537
|
flags: ['-IHn', "^<<<<<<<[ \t]"]
|
|
538
538
|
|
|
539
|
+
MixFormat:
|
|
540
|
+
enabled: false
|
|
541
|
+
description: 'Check formatting with mix format'
|
|
542
|
+
required_executable: 'mix'
|
|
543
|
+
flags: ['format', '--check-formatted']
|
|
544
|
+
include:
|
|
545
|
+
- '**/*.ex'
|
|
546
|
+
- '**/*.heex'
|
|
547
|
+
- '**/*.exs'
|
|
548
|
+
|
|
539
549
|
PuppetMetadataJsonLint:
|
|
540
550
|
enabled: false
|
|
541
551
|
description: 'Checking module metadata'
|
|
@@ -703,7 +713,7 @@ PreCommit:
|
|
|
703
713
|
enabled: false
|
|
704
714
|
description: 'Analyze with RuboCop'
|
|
705
715
|
required_executable: 'rubocop'
|
|
706
|
-
flags: ['--format=emacs', '--force-exclusion', '--display-cop-names'
|
|
716
|
+
flags: ['--format=emacs', '--force-exclusion', '--display-cop-names']
|
|
707
717
|
install_command: 'gem install rubocop'
|
|
708
718
|
include:
|
|
709
719
|
- '**/*.gemspec'
|
|
@@ -1316,6 +1326,12 @@ PrePush:
|
|
|
1316
1326
|
command: ['ruby', '-Ilib:test', '-rminitest', "-e 'exit! Minitest.run'"]
|
|
1317
1327
|
include: 'test/**/*_test.rb'
|
|
1318
1328
|
|
|
1329
|
+
MixTest:
|
|
1330
|
+
enabled: false
|
|
1331
|
+
description: 'Run mix test suite'
|
|
1332
|
+
required_executable: 'mix'
|
|
1333
|
+
flags: ['test']
|
|
1334
|
+
|
|
1319
1335
|
PhpUnit:
|
|
1320
1336
|
enabled: false
|
|
1321
1337
|
description: 'Run PhpUnit test suite'
|
|
@@ -53,10 +53,14 @@ module Overcommit
|
|
|
53
53
|
#
|
|
54
54
|
# @return [Overcommit::Configuration]
|
|
55
55
|
def load_repo_config
|
|
56
|
+
overcommit_local_yml = File.join(Overcommit::Utils.repo_root,
|
|
57
|
+
Overcommit::LOCAL_CONFIG_FILE_NAME)
|
|
56
58
|
overcommit_yml = File.join(Overcommit::Utils.repo_root,
|
|
57
59
|
Overcommit::CONFIG_FILE_NAME)
|
|
58
60
|
|
|
59
|
-
if File.exist?(overcommit_yml)
|
|
61
|
+
if File.exist?(overcommit_local_yml) && File.exist?(overcommit_yml)
|
|
62
|
+
load_file(overcommit_yml, overcommit_local_yml)
|
|
63
|
+
elsif File.exist?(overcommit_yml)
|
|
60
64
|
load_file(overcommit_yml)
|
|
61
65
|
else
|
|
62
66
|
self.class.default_configuration
|
|
@@ -64,9 +68,13 @@ module Overcommit
|
|
|
64
68
|
end
|
|
65
69
|
|
|
66
70
|
# Loads a configuration, ensuring it extends the default configuration.
|
|
67
|
-
def load_file(file)
|
|
68
|
-
|
|
69
|
-
|
|
71
|
+
def load_file(file, local_file = nil)
|
|
72
|
+
overcommit_config = self.class.load_from_file(file, default: false, logger: @log)
|
|
73
|
+
if local_file
|
|
74
|
+
local_config = self.class.load_from_file(local_file, default: false, logger: @log)
|
|
75
|
+
end
|
|
76
|
+
config = self.class.default_configuration.merge(overcommit_config)
|
|
77
|
+
config = self.class.default_configuration.merge(local_config) if local_config
|
|
70
78
|
|
|
71
79
|
if @options.fetch(:verify) { config.verify_signatures? }
|
|
72
80
|
verify_signatures(config)
|
data/lib/overcommit/constants.rb
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Overcommit::Hook::PreCommit
|
|
4
|
+
# Runs `mix format --check-formatted` against any modified ex/heex/exs files.
|
|
5
|
+
#
|
|
6
|
+
# @see https://hexdocs.pm/mix/main/Mix.Tasks.Format.html
|
|
7
|
+
class MixFormat < Base
|
|
8
|
+
# example message:
|
|
9
|
+
# ** (Mix) mix format failed due to --check-formatted.
|
|
10
|
+
# The following files are not formatted:
|
|
11
|
+
#
|
|
12
|
+
# * lib/file1.ex
|
|
13
|
+
# * lib/file2.ex
|
|
14
|
+
FILES_REGEX = /^\s+\*\s+(?<file>.+)$/.freeze
|
|
15
|
+
|
|
16
|
+
def run
|
|
17
|
+
result = execute(command, args: applicable_files)
|
|
18
|
+
return :pass if result.success?
|
|
19
|
+
|
|
20
|
+
result.stderr.scan(FILES_REGEX).flatten.
|
|
21
|
+
map { |file| message(file) }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def message(file)
|
|
27
|
+
Overcommit::Hook::Message.new(:error, file, nil, file)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -34,6 +34,12 @@ module Overcommit::Hook::PreCommit
|
|
|
34
34
|
|
|
35
35
|
private
|
|
36
36
|
|
|
37
|
+
def encoding
|
|
38
|
+
return unless @config.key?('encoding')
|
|
39
|
+
|
|
40
|
+
{ encoding: @config['encoding'] }.compact
|
|
41
|
+
end
|
|
42
|
+
|
|
37
43
|
def migration_files
|
|
38
44
|
@migration_files ||= applicable_files.select do |file|
|
|
39
45
|
file.match %r{db/migrate/.*\.rb}
|
|
@@ -47,7 +53,7 @@ module Overcommit::Hook::PreCommit
|
|
|
47
53
|
end
|
|
48
54
|
|
|
49
55
|
def schema
|
|
50
|
-
@schema ||= schema_files.map { |file| File.read(file) }.join
|
|
56
|
+
@schema ||= schema_files.map { |file| File.read(file, encoding) }.join
|
|
51
57
|
@schema.tr('_', '')
|
|
52
58
|
end
|
|
53
59
|
|
|
@@ -15,10 +15,19 @@ module Overcommit::Hook::PreCommit
|
|
|
15
15
|
rescue ArgumentError, Psych::SyntaxError => e
|
|
16
16
|
messages << Overcommit::Hook::Message.new(:error, file, nil, e.message)
|
|
17
17
|
end
|
|
18
|
+
rescue Psych::DisallowedClass => e
|
|
19
|
+
messages << error_message(file, e)
|
|
18
20
|
end
|
|
19
21
|
end
|
|
20
22
|
|
|
21
23
|
messages
|
|
22
24
|
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def error_message(file, error)
|
|
29
|
+
text = "#{file}: #{error.message}"
|
|
30
|
+
Overcommit::Hook::Message.new(:error, file, nil, text)
|
|
31
|
+
end
|
|
23
32
|
end
|
|
24
33
|
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Overcommit::Hook::PrePush
|
|
4
|
+
# Runs `mix test` test suite before push
|
|
5
|
+
#
|
|
6
|
+
# @see https://hexdocs.pm/mix/Mix.Tasks.Test.html
|
|
7
|
+
class MixTest < 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
|
|
@@ -11,9 +11,9 @@ module Overcommit::Hook::PrepareCommitMsg
|
|
|
11
11
|
# For instance, if your current branch is `123-topic` then this config
|
|
12
12
|
#
|
|
13
13
|
# branch_pattern: '(\d+)-(\w+)'
|
|
14
|
-
# replacement_text: '[#\1]'
|
|
14
|
+
# replacement_text: '[#\1] '
|
|
15
15
|
#
|
|
16
|
-
# would make this hook prepend commit messages with `[#123]`.
|
|
16
|
+
# would make this hook prepend commit messages with `[#123] `.
|
|
17
17
|
#
|
|
18
18
|
# Similarly, a replacement text of `[\1][\2]` would result in `[123][topic]`.
|
|
19
19
|
#
|
|
@@ -53,7 +53,7 @@ module Overcommit::Hook::PrepareCommitMsg
|
|
|
53
53
|
@new_template ||=
|
|
54
54
|
begin
|
|
55
55
|
curr_branch = Overcommit::GitRepo.current_branch
|
|
56
|
-
curr_branch.gsub(branch_pattern, replacement_text)
|
|
56
|
+
curr_branch.gsub(branch_pattern, replacement_text)
|
|
57
57
|
end
|
|
58
58
|
end
|
|
59
59
|
|
|
@@ -69,7 +69,7 @@ module Overcommit::Hook::PrepareCommitMsg
|
|
|
69
69
|
@replacement_text ||=
|
|
70
70
|
begin
|
|
71
71
|
if File.exist?(replacement_text_config)
|
|
72
|
-
File.read(replacement_text_config)
|
|
72
|
+
File.read(replacement_text_config).chomp
|
|
73
73
|
else
|
|
74
74
|
replacement_text_config
|
|
75
75
|
end
|
|
@@ -52,7 +52,7 @@ module Overcommit
|
|
|
52
52
|
err.rewind
|
|
53
53
|
out.rewind
|
|
54
54
|
|
|
55
|
-
Result.new(process.exit_code,
|
|
55
|
+
Result.new(process.exit_code, out.read, err.read)
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
# Spawns a new process in the background using the given array of
|
|
@@ -84,27 +84,6 @@ module Overcommit
|
|
|
84
84
|
%w[cmd.exe /c] + [args.join(' ')]
|
|
85
85
|
end
|
|
86
86
|
|
|
87
|
-
# Convert string from current locale to utf-8
|
|
88
|
-
#
|
|
89
|
-
# When running commands under windows the command output is using
|
|
90
|
-
# current system locale (depends on system lanuage) not UTF-8
|
|
91
|
-
#
|
|
92
|
-
# @param process [String]
|
|
93
|
-
# @return [String]
|
|
94
|
-
def to_utf8(string)
|
|
95
|
-
# Our encoding code doesn't work on the GitHub Actions Windows
|
|
96
|
-
# environment for unknown reasons, so just skip it in CI.
|
|
97
|
-
return string if OS.windows? && ENV['GITHUB_ACTIONS']
|
|
98
|
-
|
|
99
|
-
if Encoding.locale_charmap == 'UTF-8'
|
|
100
|
-
return string
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
ec = Encoding::Converter.new(Encoding.locale_charmap, 'UTF-8')
|
|
104
|
-
# Convert encoding, alternatively simple: string.scrub will suffice
|
|
105
|
-
ec.convert(string)
|
|
106
|
-
end
|
|
107
|
-
|
|
108
87
|
# @param process [ChildProcess]
|
|
109
88
|
# @return [Array<IO>]
|
|
110
89
|
def assign_output_streams(process)
|
data/lib/overcommit/version.rb
CHANGED
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.60.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shane da Silva
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2023-01-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: childprocess
|
|
@@ -179,6 +179,7 @@ files:
|
|
|
179
179
|
- lib/overcommit/hook/pre_commit/local_paths_in_gemfile.rb
|
|
180
180
|
- lib/overcommit/hook/pre_commit/mdl.rb
|
|
181
181
|
- lib/overcommit/hook/pre_commit/merge_conflicts.rb
|
|
182
|
+
- lib/overcommit/hook/pre_commit/mix_format.rb
|
|
182
183
|
- lib/overcommit/hook/pre_commit/nginx_test.rb
|
|
183
184
|
- lib/overcommit/hook/pre_commit/pep257.rb
|
|
184
185
|
- lib/overcommit/hook/pre_commit/pep8.rb
|
|
@@ -232,6 +233,7 @@ files:
|
|
|
232
233
|
- lib/overcommit/hook/pre_push/go_test.rb
|
|
233
234
|
- lib/overcommit/hook/pre_push/golangci_lint.rb
|
|
234
235
|
- lib/overcommit/hook/pre_push/minitest.rb
|
|
236
|
+
- lib/overcommit/hook/pre_push/mix_test.rb
|
|
235
237
|
- lib/overcommit/hook/pre_push/php_unit.rb
|
|
236
238
|
- lib/overcommit/hook/pre_push/pronto.rb
|
|
237
239
|
- lib/overcommit/hook/pre_push/protected_branches.rb
|