overcommit 0.46.0 → 0.47.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -12,7 +12,7 @@ module Overcommit::Hook::PreCommit
|
|
12
12
|
# (are caused by bad package specification, in the hands of the upstream maintainer)
|
13
13
|
# So limit reporting to errors the developer can do something about
|
14
14
|
ACTIONABLE_ERRORS = [
|
15
|
-
'Lockfile does not contain pattern'
|
15
|
+
'Lockfile does not contain pattern',
|
16
16
|
].freeze
|
17
17
|
|
18
18
|
def run
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'forwardable'
|
4
|
+
|
5
|
+
module Overcommit::Hook::PrepareCommitMsg
|
6
|
+
# Functionality common to all prepare-commit-msg hooks.
|
7
|
+
class Base < Overcommit::Hook::Base
|
8
|
+
extend Forwardable
|
9
|
+
|
10
|
+
def_delegators :@context,
|
11
|
+
:commit_message_filename, :commit_message_source, :commit, :lock
|
12
|
+
|
13
|
+
def modify_commit_message
|
14
|
+
raise 'This expects a block!' unless block_given?
|
15
|
+
# NOTE: this assumes all the hooks of the same type share the context's
|
16
|
+
# memory. If that's not the case, this won't work.
|
17
|
+
lock.synchronize do
|
18
|
+
contents = File.read(commit_message_filename)
|
19
|
+
File.open(commit_message_filename, 'w') do |f|
|
20
|
+
f << (yield contents)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Overcommit::Hook::PrepareCommitMsg
|
4
|
+
# Prepends the commit message with a message based on the branch name.
|
5
|
+
# It's possible to reference parts of the branch name through the captures in
|
6
|
+
# the `branch_pattern` regex.
|
7
|
+
class ReplaceBranch < Base
|
8
|
+
def run
|
9
|
+
return :pass unless !commit_message_source ||
|
10
|
+
commit_message_source == :commit # NOTE: avoid 'merge' and 'rebase'
|
11
|
+
Overcommit::Utils.log.debug(
|
12
|
+
"Checking if '#{Overcommit::GitRepo.current_branch}' matches #{branch_pattern}"
|
13
|
+
)
|
14
|
+
if branch_pattern.match(Overcommit::GitRepo.current_branch)
|
15
|
+
Overcommit::Utils.log.debug("Writing #{commit_message_filename} with #{new_template}")
|
16
|
+
modify_commit_message do |old_contents|
|
17
|
+
"#{new_template}\n#{old_contents}"
|
18
|
+
end
|
19
|
+
:pass
|
20
|
+
else
|
21
|
+
:warn
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def new_template
|
26
|
+
@new_template ||= Overcommit::GitRepo.current_branch.gsub(branch_pattern, replacement_text)
|
27
|
+
end
|
28
|
+
|
29
|
+
def branch_pattern
|
30
|
+
@branch_pattern ||=
|
31
|
+
begin
|
32
|
+
pattern = config['branch_pattern']
|
33
|
+
Regexp.new((pattern || '').empty? ? '\A.*\w+[-_](\d+).*\z' : pattern)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def replacement_text
|
38
|
+
@replacement_text ||=
|
39
|
+
begin
|
40
|
+
if File.exist?(replacement_text_config)
|
41
|
+
File.read(replacement_text_config)
|
42
|
+
else
|
43
|
+
replacement_text_config
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def replacement_text_config
|
49
|
+
@replacement_text_config ||= config['replacement_text']
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'fileutils'
|
2
4
|
require 'set'
|
3
5
|
|
@@ -19,7 +21,8 @@ module Overcommit::HookContext
|
|
19
21
|
# containing unicode characters, we replace the offending characters,
|
20
22
|
# since the pattern we're looking for will consist of ASCII characters
|
21
23
|
unless cmd.valid_encoding?
|
22
|
-
cmd.encode
|
24
|
+
cmd = Overcommit::Utils.parent_command.encode('UTF-16be', invalid: :replace, replace: '?').
|
25
|
+
encode('UTF-8')
|
23
26
|
end
|
24
27
|
|
25
28
|
return @amendment if
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Overcommit::HookContext
|
4
|
+
# Contains helpers related to contextual information used by prepare-commit-msg
|
5
|
+
# hooks.
|
6
|
+
class PrepareCommitMsg < Base
|
7
|
+
# Returns the name of the file that contains the commit log message
|
8
|
+
def commit_message_filename
|
9
|
+
@args[0]
|
10
|
+
end
|
11
|
+
|
12
|
+
# Returns the source of the commit message, and can be: message (if a -m or
|
13
|
+
# -F option was given); template (if a -t option was given or the
|
14
|
+
# configuration option commit.template is set); merge (if the commit is a
|
15
|
+
# merge or a .git/MERGE_MSG file exists); squash (if a .git/SQUASH_MSG file
|
16
|
+
# exists); or commit, followed by a commit SHA-1 (if a -c, -C or --amend
|
17
|
+
# option was given)
|
18
|
+
def commit_message_source
|
19
|
+
@args[1].to_sym if @args[1]
|
20
|
+
end
|
21
|
+
|
22
|
+
# Returns the commit's SHA-1.
|
23
|
+
# If commit_message_source is :commit, it's passed through the command-line.
|
24
|
+
def commit_message_source_ref
|
25
|
+
@args[2] || `git rev-parse HEAD`
|
26
|
+
end
|
27
|
+
|
28
|
+
# Lock for the pre_commit_message file. Should be shared by all
|
29
|
+
# prepare-commit-message hooks
|
30
|
+
def lock
|
31
|
+
@lock ||= Monitor.new
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|