overcommit 0.46.0 → 0.47.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/bin/overcommit +1 -0
- data/config/default.yml +53 -7
- data/lib/overcommit.rb +2 -0
- data/lib/overcommit/command_splitter.rb +2 -0
- data/lib/overcommit/configuration.rb +6 -4
- data/lib/overcommit/configuration_loader.rb +1 -1
- data/lib/overcommit/configuration_validator.rb +22 -14
- data/lib/overcommit/exceptions.rb +2 -0
- data/lib/overcommit/git_config.rb +2 -0
- data/lib/overcommit/git_repo.rb +2 -0
- data/lib/overcommit/git_version.rb +2 -0
- data/lib/overcommit/hook/base.rb +6 -4
- data/lib/overcommit/hook/commit_msg/base.rb +2 -0
- data/lib/overcommit/hook/commit_msg/capitalized_subject.rb +2 -0
- data/lib/overcommit/hook/commit_msg/empty_message.rb +2 -0
- data/lib/overcommit/hook/commit_msg/gerrit_change_id.rb +2 -0
- data/lib/overcommit/hook/commit_msg/hard_tabs.rb +2 -0
- data/lib/overcommit/hook/commit_msg/message_format.rb +2 -0
- data/lib/overcommit/hook/commit_msg/russian_novel.rb +2 -0
- data/lib/overcommit/hook/commit_msg/single_line_subject.rb +2 -0
- data/lib/overcommit/hook/commit_msg/spell_check.rb +2 -0
- data/lib/overcommit/hook/commit_msg/text_width.rb +2 -0
- data/lib/overcommit/hook/commit_msg/trailing_period.rb +2 -0
- data/lib/overcommit/hook/post_checkout/base.rb +2 -0
- data/lib/overcommit/hook/post_checkout/bower_install.rb +2 -0
- data/lib/overcommit/hook/post_checkout/bundle_install.rb +2 -0
- data/lib/overcommit/hook/post_checkout/composer_install.rb +2 -0
- data/lib/overcommit/hook/post_checkout/index_tags.rb +2 -0
- data/lib/overcommit/hook/post_checkout/npm_install.rb +2 -0
- data/lib/overcommit/hook/post_checkout/submodule_status.rb +2 -0
- data/lib/overcommit/hook/post_checkout/yarn_install.rb +2 -0
- data/lib/overcommit/hook/post_commit/base.rb +2 -0
- data/lib/overcommit/hook/post_commit/bower_install.rb +2 -0
- data/lib/overcommit/hook/post_commit/bundle_install.rb +2 -0
- data/lib/overcommit/hook/post_commit/commitplease.rb +2 -0
- data/lib/overcommit/hook/post_commit/composer_install.rb +2 -0
- data/lib/overcommit/hook/post_commit/git_guilt.rb +2 -0
- data/lib/overcommit/hook/post_commit/index_tags.rb +2 -0
- data/lib/overcommit/hook/post_commit/npm_install.rb +2 -0
- data/lib/overcommit/hook/post_commit/submodule_status.rb +2 -0
- data/lib/overcommit/hook/post_commit/yarn_install.rb +2 -0
- data/lib/overcommit/hook/post_merge/base.rb +2 -0
- data/lib/overcommit/hook/post_merge/bower_install.rb +2 -0
- data/lib/overcommit/hook/post_merge/bundle_install.rb +2 -0
- data/lib/overcommit/hook/post_merge/composer_install.rb +2 -0
- data/lib/overcommit/hook/post_merge/index_tags.rb +2 -0
- data/lib/overcommit/hook/post_merge/npm_install.rb +2 -0
- data/lib/overcommit/hook/post_merge/submodule_status.rb +2 -0
- data/lib/overcommit/hook/post_merge/yarn_install.rb +2 -0
- data/lib/overcommit/hook/post_rewrite/base.rb +2 -0
- data/lib/overcommit/hook/post_rewrite/bower_install.rb +2 -0
- data/lib/overcommit/hook/post_rewrite/bundle_install.rb +2 -0
- data/lib/overcommit/hook/post_rewrite/composer_install.rb +2 -0
- data/lib/overcommit/hook/post_rewrite/index_tags.rb +2 -0
- data/lib/overcommit/hook/post_rewrite/npm_install.rb +2 -0
- data/lib/overcommit/hook/post_rewrite/submodule_status.rb +2 -0
- data/lib/overcommit/hook/post_rewrite/yarn_install.rb +2 -0
- data/lib/overcommit/hook/pre_commit/author_email.rb +2 -0
- data/lib/overcommit/hook/pre_commit/author_name.rb +2 -0
- data/lib/overcommit/hook/pre_commit/base.rb +2 -0
- data/lib/overcommit/hook/pre_commit/broken_symlinks.rb +2 -0
- data/lib/overcommit/hook/pre_commit/bundle_audit.rb +2 -0
- data/lib/overcommit/hook/pre_commit/bundle_check.rb +2 -1
- data/lib/overcommit/hook/pre_commit/bundle_outdated.rb +2 -0
- data/lib/overcommit/hook/pre_commit/case_conflicts.rb +2 -0
- data/lib/overcommit/hook/pre_commit/chamber_compare.rb +2 -0
- data/lib/overcommit/hook/pre_commit/chamber_security.rb +2 -0
- data/lib/overcommit/hook/pre_commit/chamber_verification.rb +3 -1
- data/lib/overcommit/hook/pre_commit/coffee_lint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/cook_style.rb +35 -0
- data/lib/overcommit/hook/pre_commit/credo.rb +2 -0
- data/lib/overcommit/hook/pre_commit/css_lint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/dogma.rb +2 -0
- data/lib/overcommit/hook/pre_commit/es_lint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/execute_permissions.rb +2 -0
- data/lib/overcommit/hook/pre_commit/fasterer.rb +2 -0
- data/lib/overcommit/hook/pre_commit/fix_me.rb +2 -0
- data/lib/overcommit/hook/pre_commit/flay.rb +2 -0
- data/lib/overcommit/hook/pre_commit/foodcritic.rb +2 -0
- data/lib/overcommit/hook/pre_commit/forbidden_branches.rb +2 -0
- data/lib/overcommit/hook/pre_commit/go_lint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/go_vet.rb +2 -0
- data/lib/overcommit/hook/pre_commit/hadolint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/haml_lint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/hard_tabs.rb +2 -0
- data/lib/overcommit/hook/pre_commit/hlint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/html_hint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/html_tidy.rb +2 -0
- data/lib/overcommit/hook/pre_commit/image_optim.rb +2 -0
- data/lib/overcommit/hook/pre_commit/java_checkstyle.rb +2 -0
- data/lib/overcommit/hook/pre_commit/js_hint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/js_lint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/jscs.rb +2 -0
- data/lib/overcommit/hook/pre_commit/jsl.rb +2 -0
- data/lib/overcommit/hook/pre_commit/json_syntax.rb +2 -0
- data/lib/overcommit/hook/pre_commit/kt_lint.rb +19 -0
- data/lib/overcommit/hook/pre_commit/license_finder.rb +2 -0
- data/lib/overcommit/hook/pre_commit/license_header.rb +2 -0
- data/lib/overcommit/hook/pre_commit/line_endings.rb +2 -0
- data/lib/overcommit/hook/pre_commit/local_paths_in_gemfile.rb +2 -0
- data/lib/overcommit/hook/pre_commit/mdl.rb +2 -0
- data/lib/overcommit/hook/pre_commit/merge_conflicts.rb +2 -0
- data/lib/overcommit/hook/pre_commit/nginx_test.rb +2 -0
- data/lib/overcommit/hook/pre_commit/pep257.rb +2 -0
- data/lib/overcommit/hook/pre_commit/pep8.rb +2 -0
- data/lib/overcommit/hook/pre_commit/php_cs.rb +2 -0
- data/lib/overcommit/hook/pre_commit/php_cs_fixer.rb +2 -0
- data/lib/overcommit/hook/pre_commit/php_lint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/php_stan.rb +2 -0
- data/lib/overcommit/hook/pre_commit/pronto.rb +2 -0
- data/lib/overcommit/hook/pre_commit/puppet_lint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/puppet_metadata_json_lint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/pycodestyle.rb +2 -0
- data/lib/overcommit/hook/pre_commit/pydocstyle.rb +2 -0
- data/lib/overcommit/hook/pre_commit/pyflakes.rb +2 -0
- data/lib/overcommit/hook/pre_commit/pylint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/python_flake8.rb +2 -0
- data/lib/overcommit/hook/pre_commit/rails_best_practices.rb +2 -0
- data/lib/overcommit/hook/pre_commit/rails_schema_up_to_date.rb +2 -0
- data/lib/overcommit/hook/pre_commit/rake_target.rb +2 -0
- data/lib/overcommit/hook/pre_commit/reek.rb +2 -0
- data/lib/overcommit/hook/pre_commit/rst_lint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/rubo_cop.rb +2 -0
- data/lib/overcommit/hook/pre_commit/ruby_lint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/scalariform.rb +2 -0
- data/lib/overcommit/hook/pre_commit/scalastyle.rb +2 -0
- data/lib/overcommit/hook/pre_commit/scss_lint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/semi_standard.rb +2 -0
- data/lib/overcommit/hook/pre_commit/shell_check.rb +2 -0
- data/lib/overcommit/hook/pre_commit/slim_lint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/sqlint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/standard.rb +2 -0
- data/lib/overcommit/hook/pre_commit/stylelint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/swift_lint.rb +19 -0
- data/lib/overcommit/hook/pre_commit/terraform_format.rb +19 -0
- data/lib/overcommit/hook/pre_commit/trailing_whitespace.rb +2 -0
- data/lib/overcommit/hook/pre_commit/travis_lint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/ts_lint.rb +14 -4
- data/lib/overcommit/hook/pre_commit/vint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/w3c_css.rb +2 -0
- data/lib/overcommit/hook/pre_commit/w3c_html.rb +2 -0
- data/lib/overcommit/hook/pre_commit/xml_lint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/xml_syntax.rb +2 -0
- data/lib/overcommit/hook/pre_commit/yaml_lint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/yaml_syntax.rb +2 -0
- data/lib/overcommit/hook/pre_commit/yard_coverage.rb +2 -0
- data/lib/overcommit/hook/pre_commit/yarn_check.rb +1 -1
- data/lib/overcommit/hook/pre_push/base.rb +2 -0
- data/lib/overcommit/hook/pre_push/brakeman.rb +2 -0
- data/lib/overcommit/hook/pre_push/cargo_test.rb +2 -0
- data/lib/overcommit/hook/pre_push/minitest.rb +2 -0
- data/lib/overcommit/hook/pre_push/php_unit.rb +2 -0
- data/lib/overcommit/hook/pre_push/protected_branches.rb +2 -0
- data/lib/overcommit/hook/pre_push/pytest.rb +2 -0
- data/lib/overcommit/hook/pre_push/python_nose.rb +2 -0
- data/lib/overcommit/hook/pre_push/r_spec.rb +2 -0
- data/lib/overcommit/hook/pre_push/rake_target.rb +2 -0
- data/lib/overcommit/hook/pre_push/test_unit.rb +2 -0
- data/lib/overcommit/hook/pre_rebase/base.rb +2 -0
- data/lib/overcommit/hook/pre_rebase/merged_commits.rb +2 -0
- data/lib/overcommit/hook/prepare_commit_msg/base.rb +25 -0
- data/lib/overcommit/hook/prepare_commit_msg/replace_branch.rb +52 -0
- data/lib/overcommit/hook/shared/bower_install.rb +2 -0
- data/lib/overcommit/hook/shared/bundle_install.rb +2 -0
- data/lib/overcommit/hook/shared/composer_install.rb +2 -0
- data/lib/overcommit/hook/shared/index_tags.rb +2 -0
- data/lib/overcommit/hook/shared/npm_install.rb +2 -0
- data/lib/overcommit/hook/shared/rake_target.rb +2 -0
- data/lib/overcommit/hook/shared/submodule_status.rb +2 -0
- data/lib/overcommit/hook/shared/yarn_install.rb +2 -0
- data/lib/overcommit/hook_context.rb +2 -0
- data/lib/overcommit/hook_context/base.rb +2 -0
- data/lib/overcommit/hook_context/commit_msg.rb +2 -0
- data/lib/overcommit/hook_context/post_checkout.rb +2 -0
- data/lib/overcommit/hook_context/post_commit.rb +2 -0
- data/lib/overcommit/hook_context/post_merge.rb +2 -0
- data/lib/overcommit/hook_context/post_rewrite.rb +2 -0
- data/lib/overcommit/hook_context/pre_commit.rb +4 -1
- data/lib/overcommit/hook_context/pre_push.rb +2 -0
- data/lib/overcommit/hook_context/pre_rebase.rb +2 -0
- data/lib/overcommit/hook_context/prepare_commit_msg.rb +34 -0
- data/lib/overcommit/hook_context/run_all.rb +2 -0
- data/lib/overcommit/hook_loader/base.rb +2 -0
- data/lib/overcommit/hook_loader/built_in_hook_loader.rb +2 -0
- data/lib/overcommit/hook_loader/plugin_hook_loader.rb +2 -0
- data/lib/overcommit/hook_runner.rb +2 -0
- data/lib/overcommit/hook_signer.rb +2 -0
- data/lib/overcommit/installer.rb +2 -0
- data/lib/overcommit/interrupt_handler.rb +2 -0
- data/lib/overcommit/logger.rb +3 -1
- data/lib/overcommit/os.rb +2 -0
- data/lib/overcommit/printer.rb +2 -0
- data/lib/overcommit/subprocess.rb +2 -0
- data/lib/overcommit/utils.rb +3 -1
- data/lib/overcommit/utils/file_utils.rb +2 -0
- data/lib/overcommit/utils/messages_utils.rb +2 -0
- data/lib/overcommit/version.rb +1 -1
- data/template-dir/hooks/commit-msg +1 -0
- data/template-dir/hooks/overcommit-hook +1 -0
- data/template-dir/hooks/post-checkout +1 -0
- data/template-dir/hooks/post-commit +1 -0
- data/template-dir/hooks/post-merge +1 -0
- data/template-dir/hooks/post-rewrite +1 -0
- data/template-dir/hooks/pre-commit +1 -0
- data/template-dir/hooks/pre-push +1 -0
- data/template-dir/hooks/pre-rebase +1 -0
- data/template-dir/hooks/prepare-commit-msg +116 -0
- metadata +11 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5cbfe83620ba468c0053d8303aa80350c50db1fe8a3d90028d0ae2794c219834
|
|
4
|
+
data.tar.gz: 9f3f6b7d8675cb83e65dc554d9ebe76de0f3287acfcb7f2161c3880ad315ceb9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a683f507f19caa0ab810b8b7635ddf4672d5daa3b2519090278bbc23da8e7662a3e1d95743dd61f2f12c1f308b1678fec6461c3d54bde8acfa4c89d2d03fc39b
|
|
7
|
+
data.tar.gz: 0b03b050b2e46d24e8d524de3d0b1b11c895173161d55f9e63224710191419a57f7d7bf8b8ae6e14f6d53f601ac2cecb85dd430e25105588e87b26b244047bc7
|
data/bin/overcommit
CHANGED
data/config/default.yml
CHANGED
|
@@ -230,6 +230,16 @@ PreCommit:
|
|
|
230
230
|
install_command: 'npm install -g coffeelint'
|
|
231
231
|
include: '**/*.coffee'
|
|
232
232
|
|
|
233
|
+
CookStyle:
|
|
234
|
+
enabled: false
|
|
235
|
+
description: 'Analyze with CookStyle'
|
|
236
|
+
required_executable: 'cookstyle'
|
|
237
|
+
flags: ['--format=emacs', '--force-exclusion', '--display-cop-names']
|
|
238
|
+
install_command: 'gem install cookstyle'
|
|
239
|
+
include:
|
|
240
|
+
- '**/*.rb'
|
|
241
|
+
- '**/*.erb'
|
|
242
|
+
|
|
233
243
|
Credo:
|
|
234
244
|
enabled: false
|
|
235
245
|
description: 'Analyze with credo'
|
|
@@ -424,6 +434,13 @@ PreCommit:
|
|
|
424
434
|
install_command: 'gem install json'
|
|
425
435
|
include: '**/*.json'
|
|
426
436
|
|
|
437
|
+
KtLint:
|
|
438
|
+
enabled: false
|
|
439
|
+
description: 'Analyze with KtLint'
|
|
440
|
+
required_executable: 'ktlint'
|
|
441
|
+
flags: []
|
|
442
|
+
include: '**/*.kt'
|
|
443
|
+
|
|
427
444
|
LicenseFinder:
|
|
428
445
|
enabled: false
|
|
429
446
|
description: 'Analyze with LicenseFinder'
|
|
@@ -612,7 +629,7 @@ PreCommit:
|
|
|
612
629
|
enabled: false
|
|
613
630
|
description: 'Analyze with Reek'
|
|
614
631
|
required_executable: 'reek'
|
|
615
|
-
flags: ['--single-line', '--no-color']
|
|
632
|
+
flags: ['--single-line', '--no-color', '--force-exclusion']
|
|
616
633
|
install_command: 'gem install reek'
|
|
617
634
|
include:
|
|
618
635
|
- '**/*.gemspec'
|
|
@@ -722,12 +739,27 @@ PreCommit:
|
|
|
722
739
|
- '**/*.css'
|
|
723
740
|
- '**/*.less'
|
|
724
741
|
|
|
742
|
+
SwiftLint:
|
|
743
|
+
enabled: false
|
|
744
|
+
description: 'Analyze with SwiftLint'
|
|
745
|
+
required_executable: 'swiftlint'
|
|
746
|
+
flags: ['lint', '--strict']
|
|
747
|
+
install_command: 'brew install swiftlint'
|
|
748
|
+
include: '**/*.swift'
|
|
749
|
+
|
|
750
|
+
TerraformFormat:
|
|
751
|
+
enabled: false
|
|
752
|
+
description: 'Analyze with Terraform'
|
|
753
|
+
required_executable: 'terraform'
|
|
754
|
+
flags: ['fmt', '-check=true', '-diff=false']
|
|
755
|
+
include: '**/*.tf'
|
|
756
|
+
|
|
725
757
|
TsLint:
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
758
|
+
enabled: false
|
|
759
|
+
description: 'Analyze with TSLint'
|
|
760
|
+
required_executable: 'tslint'
|
|
761
|
+
install_command: 'npm install -g tslint typescript'
|
|
762
|
+
include: '**/*.ts'
|
|
731
763
|
|
|
732
764
|
TrailingWhitespace:
|
|
733
765
|
enabled: false
|
|
@@ -769,7 +801,7 @@ PreCommit:
|
|
|
769
801
|
description: 'Analyze with W3C HTML validation service'
|
|
770
802
|
required_library: 'w3c_validators'
|
|
771
803
|
install_command: 'gem install w3c_validators'
|
|
772
|
-
validator_uri: '
|
|
804
|
+
validator_uri: 'https://validator.w3.org/nu'
|
|
773
805
|
charset: 'utf-8'
|
|
774
806
|
doctype: 'HTML5'
|
|
775
807
|
include:
|
|
@@ -1143,6 +1175,20 @@ PostRewrite:
|
|
|
1143
1175
|
- 'package.json'
|
|
1144
1176
|
- 'yarn.lock'
|
|
1145
1177
|
|
|
1178
|
+
# Hooks that run during the `prepare-commit-msg` hook.
|
|
1179
|
+
PrepareCommitMsg:
|
|
1180
|
+
ALL:
|
|
1181
|
+
requires_files: false
|
|
1182
|
+
required: false
|
|
1183
|
+
quiet: false
|
|
1184
|
+
|
|
1185
|
+
ReplaceBranch:
|
|
1186
|
+
enabled: false
|
|
1187
|
+
description: 'Prepends the commit message with text based on the branch name'
|
|
1188
|
+
branch_pattern: '\A.*\w+[-_](\d+).*\z'
|
|
1189
|
+
replacement_text: '[#\1]'
|
|
1190
|
+
on_fail: warn
|
|
1191
|
+
|
|
1146
1192
|
# Hooks that run during `git push`, after remote refs have been updated but
|
|
1147
1193
|
# before any objects have been transferred.
|
|
1148
1194
|
PrePush:
|
data/lib/overcommit.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'digest'
|
|
2
4
|
require 'json'
|
|
3
5
|
|
|
@@ -41,7 +43,7 @@ module Overcommit
|
|
|
41
43
|
@concurrency ||=
|
|
42
44
|
begin
|
|
43
45
|
cores = Overcommit::Utils.processor_count
|
|
44
|
-
content = @hash.fetch('concurrency'
|
|
46
|
+
content = @hash.fetch('concurrency') { '%<processors>d' }
|
|
45
47
|
if content.is_a?(String)
|
|
46
48
|
concurrency_expr = content % { processors: cores }
|
|
47
49
|
|
|
@@ -154,7 +156,7 @@ module Overcommit
|
|
|
154
156
|
# environment variables.
|
|
155
157
|
def apply_environment!(hook_context, env)
|
|
156
158
|
skipped_hooks = "#{env['SKIP']} #{env['SKIP_CHECKS']} #{env['SKIP_HOOKS']}".split(/[:, ]/)
|
|
157
|
-
only_hooks = env.fetch('ONLY'
|
|
159
|
+
only_hooks = env.fetch('ONLY') { '' }.split(/[:, ]/)
|
|
158
160
|
hook_type = hook_context.hook_class_name
|
|
159
161
|
|
|
160
162
|
if only_hooks.any? || skipped_hooks.include?('all') || skipped_hooks.include?('ALL')
|
|
@@ -252,7 +254,7 @@ module Overcommit
|
|
|
252
254
|
private
|
|
253
255
|
|
|
254
256
|
def ad_hoc_hook?(hook_context, hook_name)
|
|
255
|
-
ad_hoc_conf = @hash.fetch(hook_context.hook_class_name
|
|
257
|
+
ad_hoc_conf = @hash.fetch(hook_context.hook_class_name) { {} }.fetch(hook_name) { {} }
|
|
256
258
|
|
|
257
259
|
# Ad hoc hooks are neither built-in nor have a plugin file written but
|
|
258
260
|
# still have a `command` specified to be run
|
|
@@ -282,7 +284,7 @@ module Overcommit
|
|
|
282
284
|
hook_context_or_type.hook_class_name
|
|
283
285
|
end
|
|
284
286
|
|
|
285
|
-
individual_enabled = @hash[hook_type].fetch(hook_name
|
|
287
|
+
individual_enabled = @hash[hook_type].fetch(hook_name) { {} }['enabled']
|
|
286
288
|
return individual_enabled unless individual_enabled.nil?
|
|
287
289
|
|
|
288
290
|
all_enabled = @hash[hook_type]['ALL']['enabled']
|
|
@@ -65,7 +65,7 @@ module Overcommit
|
|
|
65
65
|
config = self.class.load_from_file(file, default: false, logger: @log)
|
|
66
66
|
config = self.class.default_configuration.merge(config)
|
|
67
67
|
|
|
68
|
-
if @options.fetch(:verify
|
|
68
|
+
if @options.fetch(:verify) { config.verify_signatures? }
|
|
69
69
|
verify_signatures(config)
|
|
70
70
|
end
|
|
71
71
|
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# rubocop:disable Metrics/ClassLength, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
|
2
4
|
module Overcommit
|
|
3
5
|
# Validates and normalizes a configuration.
|
|
4
6
|
class ConfigurationValidator
|
|
@@ -57,8 +59,8 @@ module Overcommit
|
|
|
57
59
|
errors = []
|
|
58
60
|
|
|
59
61
|
Overcommit::Utils.supported_hook_type_classes.each do |hook_type|
|
|
60
|
-
hash.fetch(hook_type
|
|
61
|
-
hook_env = hook_config.fetch('env'
|
|
62
|
+
hash.fetch(hook_type) { {} }.each do |hook_name, hook_config|
|
|
63
|
+
hook_env = hook_config.fetch('env') { {} }
|
|
62
64
|
|
|
63
65
|
unless hook_env.is_a?(Hash)
|
|
64
66
|
errors << "#{hook_type}::#{hook_name} has an invalid `env` specified: " \
|
|
@@ -82,8 +84,10 @@ module Overcommit
|
|
|
82
84
|
end
|
|
83
85
|
|
|
84
86
|
if errors.any?
|
|
85
|
-
|
|
86
|
-
|
|
87
|
+
if @log
|
|
88
|
+
@log.error errors.join("\n")
|
|
89
|
+
@log.newline
|
|
90
|
+
end
|
|
87
91
|
raise Overcommit::Exceptions::ConfigurationError,
|
|
88
92
|
'One or more hooks had an invalid `env` configuration option'
|
|
89
93
|
end
|
|
@@ -95,7 +99,7 @@ module Overcommit
|
|
|
95
99
|
errors = []
|
|
96
100
|
|
|
97
101
|
Overcommit::Utils.supported_hook_type_classes.each do |hook_type|
|
|
98
|
-
hash.fetch(hook_type
|
|
102
|
+
hash.fetch(hook_type) { {} }.each_key do |hook_name|
|
|
99
103
|
next if hook_name == 'ALL'
|
|
100
104
|
|
|
101
105
|
unless hook_name =~ /\A[A-Za-z0-9]+\z/
|
|
@@ -107,8 +111,10 @@ module Overcommit
|
|
|
107
111
|
end
|
|
108
112
|
|
|
109
113
|
if errors.any?
|
|
110
|
-
|
|
111
|
-
|
|
114
|
+
if @log
|
|
115
|
+
@log.error errors.join("\n")
|
|
116
|
+
@log.newline
|
|
117
|
+
end
|
|
112
118
|
raise Overcommit::Exceptions::ConfigurationError,
|
|
113
119
|
'One or more hooks had invalid names'
|
|
114
120
|
end
|
|
@@ -122,7 +128,7 @@ module Overcommit
|
|
|
122
128
|
any_warnings = false
|
|
123
129
|
|
|
124
130
|
Overcommit::Utils.supported_hook_type_classes.each do |hook_type|
|
|
125
|
-
hash.fetch(hook_type
|
|
131
|
+
hash.fetch(hook_type) { {} }.each do |hook_name, hook_config|
|
|
126
132
|
next if hook_name == 'ALL'
|
|
127
133
|
|
|
128
134
|
if hook_config['enabled'].nil?
|
|
@@ -143,8 +149,8 @@ module Overcommit
|
|
|
143
149
|
|
|
144
150
|
errors = []
|
|
145
151
|
Overcommit::Utils.supported_hook_type_classes.each do |hook_type|
|
|
146
|
-
hash.fetch(hook_type
|
|
147
|
-
processors = hook_config.fetch('processors'
|
|
152
|
+
hash.fetch(hook_type) { {} }.each do |hook_name, hook_config|
|
|
153
|
+
processors = hook_config.fetch('processors') { 1 }
|
|
148
154
|
if processors > concurrency
|
|
149
155
|
errors << "#{hook_type}::#{hook_name} `processors` value " \
|
|
150
156
|
"(#{processors}) is larger than the global `concurrency` " \
|
|
@@ -154,8 +160,10 @@ module Overcommit
|
|
|
154
160
|
end
|
|
155
161
|
|
|
156
162
|
if errors.any?
|
|
157
|
-
|
|
158
|
-
|
|
163
|
+
if @log
|
|
164
|
+
@log.error errors.join("\n")
|
|
165
|
+
@log.newline
|
|
166
|
+
end
|
|
159
167
|
raise Overcommit::Exceptions::ConfigurationError,
|
|
160
168
|
'One or more hooks had invalid `processor` value configured'
|
|
161
169
|
end
|
|
@@ -175,4 +183,4 @@ module Overcommit
|
|
|
175
183
|
end
|
|
176
184
|
end
|
|
177
185
|
end
|
|
178
|
-
# rubocop:enable Metrics/ClassLength, Metrics/CyclomaticComplexity, Metrics/
|
|
186
|
+
# rubocop:enable Metrics/ClassLength, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
data/lib/overcommit/git_repo.rb
CHANGED
data/lib/overcommit/hook/base.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'forwardable'
|
|
2
4
|
require 'overcommit/message_processor'
|
|
3
5
|
|
|
@@ -42,7 +44,7 @@ module Overcommit::Hook
|
|
|
42
44
|
if output = check_for_requirements
|
|
43
45
|
status = :fail
|
|
44
46
|
else
|
|
45
|
-
result = Overcommit::Utils.with_environment(@config.fetch('env'
|
|
47
|
+
result = Overcommit::Utils.with_environment(@config.fetch('env') { {} }) { run }
|
|
46
48
|
status, output = process_hook_return_value(result)
|
|
47
49
|
end
|
|
48
50
|
|
|
@@ -66,7 +68,7 @@ module Overcommit::Hook
|
|
|
66
68
|
end
|
|
67
69
|
|
|
68
70
|
def processors
|
|
69
|
-
@config.fetch('processors'
|
|
71
|
+
@config.fetch('processors') { 1 }
|
|
70
72
|
end
|
|
71
73
|
|
|
72
74
|
def quiet?
|
|
@@ -270,9 +272,9 @@ module Overcommit::Hook
|
|
|
270
272
|
def transform_status(status)
|
|
271
273
|
case status
|
|
272
274
|
when :fail
|
|
273
|
-
@config.fetch('on_fail'
|
|
275
|
+
@config.fetch('on_fail') { :fail }.to_sym
|
|
274
276
|
when :warn
|
|
275
|
-
@config.fetch('on_warn'
|
|
277
|
+
@config.fetch('on_warn') { :warn }.to_sym
|
|
276
278
|
else
|
|
277
279
|
status
|
|
278
280
|
end
|