overcommit 0.59.1 → 0.61.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7cef58909a16cc684b9f11e232eb5329d093fc7ceeeb5a4d9434459d0169395c
4
- data.tar.gz: e5839562da56c532ce493bf0582061ec41a873342a79c70f516302ee27e5b910
3
+ metadata.gz: 6ecfff59af8eed6358b9f6b03d50d6378ac9cd9ae5bd48b7cd5a2e8110223562
4
+ data.tar.gz: 340214649a288a6728a37fdf827bbf4ff35d1940201a009dcfe3feae005839aa
5
5
  SHA512:
6
- metadata.gz: d3c89be131243e7010236164d1b6ebd480e62865c63960d965c12a48c40c6ad726b2fba61c7daaf0732a0a865ac8f45a71486413b5c74c9d4bb91c190a02360d
7
- data.tar.gz: 66996e68b9c3eee70c4d636071e23981537a2e0911c4fef6c519a23707c34252ed9a5ca6348fd796cd9f151138639d9f9667d497ea2fae816e98d4b305512bc6
6
+ metadata.gz: 1210bc1c11220a462ed4e2f4f75e6becb3e97472d74787be10321f08a233238c8f3071a0dc6bfcf848060c351906d69f9122d670bf8ad91f6b9ea6110c5dffc2
7
+ data.tar.gz: 3963037483e0a132b9b6ce6da860f23e33f7b309c4b67fced3497f034544b98966469232a6f1195db737ef6ff5d4ce5d2436ae72b6a323d80fc91624b8d449af
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'
@@ -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,11 @@ module Overcommit
64
68
  end
65
69
 
66
70
  # Loads a configuration, ensuring it extends the default configuration.
67
- def load_file(file)
68
- config = self.class.load_from_file(file, default: false, logger: @log)
69
- config = self.class.default_configuration.merge(config)
71
+ def load_file(file, local_file = nil)
72
+ overcommit_config = self.class.load_from_file(file, default: false, logger: @log)
73
+ l_config = self.class.load_from_file(local_file, default: false, logger: @log) if local_file
74
+ config = self.class.default_configuration.merge(overcommit_config)
75
+ config = config.merge(l_config) if l_config
70
76
 
71
77
  if @options.fetch(:verify) { config.verify_signatures? }
72
78
  verify_signatures(config)
@@ -4,6 +4,7 @@
4
4
  module Overcommit
5
5
  HOME = File.expand_path(File.join(File.dirname(__FILE__), '..', '..')).freeze
6
6
  CONFIG_FILE_NAME = '.overcommit.yml'
7
+ LOCAL_CONFIG_FILE_NAME = '.local-overcommit.yml'
7
8
 
8
9
  HOOK_DIRECTORY = File.join(HOME, 'lib', 'overcommit', 'hook').freeze
9
10
 
@@ -6,7 +6,7 @@ module Overcommit::Hook::PreCommit
6
6
  #
7
7
  # @see http://bundler.io/
8
8
  class BundleCheck < Base
9
- LOCK_FILE = 'Gemfile.lock'
9
+ LOCK_FILE = File.basename(ENV['BUNDLE_GEMFILE'] || 'Gemfile') + '.lock'
10
10
 
11
11
  def run
12
12
  # Ignore if Gemfile.lock is not tracked by git
@@ -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).strip
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
@@ -85,7 +85,7 @@ module Overcommit::Hook::PrepareCommitMsg
85
85
  end
86
86
 
87
87
  def skip?
88
- skipped_commit_types.include?(commit_message_source)
88
+ super || skipped_commit_types.include?(commit_message_source)
89
89
  end
90
90
  end
91
91
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Defines the gem version.
4
4
  module Overcommit
5
- VERSION = '0.59.1'
5
+ VERSION = '0.61.0'
6
6
  end
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.59.1
4
+ version: 0.61.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: 2022-05-03 00:00:00.000000000 Z
11
+ date: 2023-12-13 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
@@ -316,8 +318,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
316
318
  - !ruby/object:Gem::Version
317
319
  version: '0'
318
320
  requirements: []
319
- rubygems_version: 3.1.6
320
- signing_key:
321
+ rubygems_version: 3.4.10
322
+ signing_key:
321
323
  specification_version: 4
322
324
  summary: Git hook manager
323
325
  test_files: []