overcommit-jeygeethanmedia 0.53.1
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 +7 -0
- data/bin/overcommit +50 -0
- data/config/default.yml +1356 -0
- data/config/starter.yml +33 -0
- data/lib/overcommit.rb +26 -0
- data/lib/overcommit/cli.rb +223 -0
- data/lib/overcommit/command_splitter.rb +146 -0
- data/lib/overcommit/configuration.rb +350 -0
- data/lib/overcommit/configuration_loader.rb +96 -0
- data/lib/overcommit/configuration_validator.rb +186 -0
- data/lib/overcommit/constants.rb +12 -0
- data/lib/overcommit/exceptions.rb +52 -0
- data/lib/overcommit/git_config.rb +22 -0
- data/lib/overcommit/git_repo.rb +286 -0
- data/lib/overcommit/git_version.rb +17 -0
- data/lib/overcommit/hook/base.rb +294 -0
- data/lib/overcommit/hook/commit_msg/base.rb +14 -0
- data/lib/overcommit/hook/commit_msg/capitalized_subject.rb +25 -0
- data/lib/overcommit/hook/commit_msg/empty_message.rb +12 -0
- data/lib/overcommit/hook/commit_msg/gerrit_change_id.rb +22 -0
- data/lib/overcommit/hook/commit_msg/hard_tabs.rb +17 -0
- data/lib/overcommit/hook/commit_msg/message_format.rb +31 -0
- data/lib/overcommit/hook/commit_msg/russian_novel.rb +16 -0
- data/lib/overcommit/hook/commit_msg/single_line_subject.rb +16 -0
- data/lib/overcommit/hook/commit_msg/spell_check.rb +45 -0
- data/lib/overcommit/hook/commit_msg/text_width.rb +56 -0
- data/lib/overcommit/hook/commit_msg/trailing_period.rb +16 -0
- data/lib/overcommit/hook/post_checkout/base.rb +22 -0
- data/lib/overcommit/hook/post_checkout/bower_install.rb +13 -0
- data/lib/overcommit/hook/post_checkout/bundle_install.rb +13 -0
- data/lib/overcommit/hook/post_checkout/composer_install.rb +13 -0
- data/lib/overcommit/hook/post_checkout/index_tags.rb +12 -0
- data/lib/overcommit/hook/post_checkout/npm_install.rb +13 -0
- data/lib/overcommit/hook/post_checkout/submodule_status.rb +12 -0
- data/lib/overcommit/hook/post_checkout/yarn_install.rb +13 -0
- data/lib/overcommit/hook/post_commit/base.rb +12 -0
- data/lib/overcommit/hook/post_commit/bower_install.rb +13 -0
- data/lib/overcommit/hook/post_commit/bundle_install.rb +13 -0
- data/lib/overcommit/hook/post_commit/commitplease.rb +16 -0
- data/lib/overcommit/hook/post_commit/composer_install.rb +13 -0
- data/lib/overcommit/hook/post_commit/git_guilt.rb +43 -0
- data/lib/overcommit/hook/post_commit/index_tags.rb +12 -0
- data/lib/overcommit/hook/post_commit/npm_install.rb +13 -0
- data/lib/overcommit/hook/post_commit/submodule_status.rb +12 -0
- data/lib/overcommit/hook/post_commit/yarn_install.rb +13 -0
- data/lib/overcommit/hook/post_merge/base.rb +12 -0
- data/lib/overcommit/hook/post_merge/bower_install.rb +13 -0
- data/lib/overcommit/hook/post_merge/bundle_install.rb +13 -0
- data/lib/overcommit/hook/post_merge/composer_install.rb +13 -0
- data/lib/overcommit/hook/post_merge/index_tags.rb +12 -0
- data/lib/overcommit/hook/post_merge/npm_install.rb +13 -0
- data/lib/overcommit/hook/post_merge/submodule_status.rb +12 -0
- data/lib/overcommit/hook/post_merge/yarn_install.rb +13 -0
- data/lib/overcommit/hook/post_rewrite/base.rb +12 -0
- data/lib/overcommit/hook/post_rewrite/bower_install.rb +13 -0
- data/lib/overcommit/hook/post_rewrite/bundle_install.rb +13 -0
- data/lib/overcommit/hook/post_rewrite/composer_install.rb +13 -0
- data/lib/overcommit/hook/post_rewrite/index_tags.rb +19 -0
- data/lib/overcommit/hook/post_rewrite/npm_install.rb +13 -0
- data/lib/overcommit/hook/post_rewrite/submodule_status.rb +12 -0
- data/lib/overcommit/hook/post_rewrite/yarn_install.rb +13 -0
- data/lib/overcommit/hook/pre_commit/author_email.rb +26 -0
- data/lib/overcommit/hook/pre_commit/author_name.rb +25 -0
- data/lib/overcommit/hook/pre_commit/base.rb +19 -0
- data/lib/overcommit/hook/pre_commit/berksfile_check.rb +24 -0
- data/lib/overcommit/hook/pre_commit/broken_symlinks.rb +17 -0
- data/lib/overcommit/hook/pre_commit/bundle_audit.rb +24 -0
- data/lib/overcommit/hook/pre_commit/bundle_check.rb +32 -0
- data/lib/overcommit/hook/pre_commit/bundle_outdated.rb +25 -0
- data/lib/overcommit/hook/pre_commit/case_conflicts.rb +27 -0
- data/lib/overcommit/hook/pre_commit/chamber_compare.rb +43 -0
- data/lib/overcommit/hook/pre_commit/chamber_security.rb +15 -0
- data/lib/overcommit/hook/pre_commit/chamber_verification.rb +36 -0
- data/lib/overcommit/hook/pre_commit/code_spell_check.rb +36 -0
- data/lib/overcommit/hook/pre_commit/coffee_lint.rb +35 -0
- data/lib/overcommit/hook/pre_commit/cook_style.rb +35 -0
- data/lib/overcommit/hook/pre_commit/credo.rb +27 -0
- data/lib/overcommit/hook/pre_commit/css_lint.rb +26 -0
- data/lib/overcommit/hook/pre_commit/dogma.rb +33 -0
- data/lib/overcommit/hook/pre_commit/es_lint.rb +38 -0
- data/lib/overcommit/hook/pre_commit/execute_permissions.rb +76 -0
- data/lib/overcommit/hook/pre_commit/fasterer.rb +25 -0
- data/lib/overcommit/hook/pre_commit/file_size.rb +47 -0
- data/lib/overcommit/hook/pre_commit/fix_me.rb +17 -0
- data/lib/overcommit/hook/pre_commit/flay.rb +38 -0
- data/lib/overcommit/hook/pre_commit/foodcritic.rb +149 -0
- data/lib/overcommit/hook/pre_commit/forbidden_branches.rb +26 -0
- data/lib/overcommit/hook/pre_commit/ginkgo_focus.rb +23 -0
- data/lib/overcommit/hook/pre_commit/go_fmt.rb +17 -0
- data/lib/overcommit/hook/pre_commit/go_lint.rb +29 -0
- data/lib/overcommit/hook/pre_commit/go_vet.rb +24 -0
- data/lib/overcommit/hook/pre_commit/golangci_lint.rb +21 -0
- data/lib/overcommit/hook/pre_commit/hadolint.rb +27 -0
- data/lib/overcommit/hook/pre_commit/haml_lint.rb +23 -0
- data/lib/overcommit/hook/pre_commit/hard_tabs.rb +15 -0
- data/lib/overcommit/hook/pre_commit/hlint.rb +34 -0
- data/lib/overcommit/hook/pre_commit/html_hint.rb +23 -0
- data/lib/overcommit/hook/pre_commit/html_tidy.rb +30 -0
- data/lib/overcommit/hook/pre_commit/image_optim.rb +28 -0
- data/lib/overcommit/hook/pre_commit/java_checkstyle.rb +27 -0
- data/lib/overcommit/hook/pre_commit/js_hint.rb +23 -0
- data/lib/overcommit/hook/pre_commit/js_lint.rb +22 -0
- data/lib/overcommit/hook/pre_commit/jscs.rb +27 -0
- data/lib/overcommit/hook/pre_commit/jsl.rb +28 -0
- data/lib/overcommit/hook/pre_commit/json_syntax.rb +21 -0
- data/lib/overcommit/hook/pre_commit/kt_lint.rb +19 -0
- data/lib/overcommit/hook/pre_commit/license_finder.rb +14 -0
- data/lib/overcommit/hook/pre_commit/license_header.rb +48 -0
- data/lib/overcommit/hook/pre_commit/line_endings.rb +77 -0
- data/lib/overcommit/hook/pre_commit/local_paths_in_gemfile.rb +16 -0
- data/lib/overcommit/hook/pre_commit/mdl.rb +29 -0
- data/lib/overcommit/hook/pre_commit/merge_conflicts.rb +16 -0
- data/lib/overcommit/hook/pre_commit/nginx_test.rb +26 -0
- data/lib/overcommit/hook/pre_commit/pep257.rb +23 -0
- data/lib/overcommit/hook/pre_commit/pep8.rb +23 -0
- data/lib/overcommit/hook/pre_commit/php_cs.rb +43 -0
- data/lib/overcommit/hook/pre_commit/php_cs_fixer.rb +57 -0
- data/lib/overcommit/hook/pre_commit/php_lint.rb +44 -0
- data/lib/overcommit/hook/pre_commit/php_stan.rb +30 -0
- data/lib/overcommit/hook/pre_commit/pronto.rb +12 -0
- data/lib/overcommit/hook/pre_commit/puppet_lint.rb +26 -0
- data/lib/overcommit/hook/pre_commit/puppet_metadata_json_lint.rb +29 -0
- data/lib/overcommit/hook/pre_commit/pycodestyle.rb +23 -0
- data/lib/overcommit/hook/pre_commit/pydocstyle.rb +23 -0
- data/lib/overcommit/hook/pre_commit/pyflakes.rb +32 -0
- data/lib/overcommit/hook/pre_commit/pylint.rb +32 -0
- data/lib/overcommit/hook/pre_commit/python_flake8.rb +32 -0
- data/lib/overcommit/hook/pre_commit/rails_best_practices.rb +34 -0
- data/lib/overcommit/hook/pre_commit/rails_schema_up_to_date.rb +58 -0
- data/lib/overcommit/hook/pre_commit/rake_target.rb +12 -0
- data/lib/overcommit/hook/pre_commit/reek.rb +26 -0
- data/lib/overcommit/hook/pre_commit/rst_lint.rb +27 -0
- data/lib/overcommit/hook/pre_commit/rubo_cop.rb +35 -0
- data/lib/overcommit/hook/pre_commit/ruby_lint.rb +23 -0
- data/lib/overcommit/hook/pre_commit/ruby_syntax.rb +27 -0
- data/lib/overcommit/hook/pre_commit/scalariform.rb +22 -0
- data/lib/overcommit/hook/pre_commit/scalastyle.rb +31 -0
- data/lib/overcommit/hook/pre_commit/scss_lint.rb +43 -0
- data/lib/overcommit/hook/pre_commit/semi_standard.rb +23 -0
- data/lib/overcommit/hook/pre_commit/shell_check.rb +23 -0
- data/lib/overcommit/hook/pre_commit/slim_lint.rb +23 -0
- data/lib/overcommit/hook/pre_commit/sqlint.rb +26 -0
- data/lib/overcommit/hook/pre_commit/standard.rb +23 -0
- data/lib/overcommit/hook/pre_commit/stylelint.rb +23 -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 +15 -0
- data/lib/overcommit/hook/pre_commit/travis_lint.rb +15 -0
- data/lib/overcommit/hook/pre_commit/ts_lint.rb +28 -0
- data/lib/overcommit/hook/pre_commit/vint.rb +22 -0
- data/lib/overcommit/hook/pre_commit/w3c_css.rb +67 -0
- data/lib/overcommit/hook/pre_commit/w3c_html.rb +64 -0
- data/lib/overcommit/hook/pre_commit/xml_lint.rb +24 -0
- data/lib/overcommit/hook/pre_commit/xml_syntax.rb +21 -0
- data/lib/overcommit/hook/pre_commit/yaml_lint.rb +18 -0
- data/lib/overcommit/hook/pre_commit/yaml_syntax.rb +20 -0
- data/lib/overcommit/hook/pre_commit/yard_coverage.rb +90 -0
- data/lib/overcommit/hook/pre_commit/yarn_check.rb +37 -0
- data/lib/overcommit/hook/pre_push/base.rb +33 -0
- data/lib/overcommit/hook/pre_push/brakeman.rb +15 -0
- data/lib/overcommit/hook/pre_push/cargo_test.rb +12 -0
- data/lib/overcommit/hook/pre_push/go_test.rb +14 -0
- data/lib/overcommit/hook/pre_push/golangci_lint.rb +16 -0
- data/lib/overcommit/hook/pre_push/minitest.rb +20 -0
- data/lib/overcommit/hook/pre_push/php_unit.rb +16 -0
- data/lib/overcommit/hook/pre_push/pronto.rb +12 -0
- data/lib/overcommit/hook/pre_push/protected_branches.rb +74 -0
- data/lib/overcommit/hook/pre_push/pytest.rb +16 -0
- data/lib/overcommit/hook/pre_push/python_nose.rb +16 -0
- data/lib/overcommit/hook/pre_push/r_spec.rb +16 -0
- data/lib/overcommit/hook/pre_push/rake_target.rb +12 -0
- data/lib/overcommit/hook/pre_push/test_unit.rb +16 -0
- data/lib/overcommit/hook/pre_rebase/base.rb +14 -0
- data/lib/overcommit/hook/pre_rebase/merged_commits.rb +31 -0
- data/lib/overcommit/hook/prepare_commit_msg/base.rb +25 -0
- data/lib/overcommit/hook/prepare_commit_msg/replace_branch.rb +57 -0
- data/lib/overcommit/hook/shared/bower_install.rb +15 -0
- data/lib/overcommit/hook/shared/bundle_install.rb +15 -0
- data/lib/overcommit/hook/shared/composer_install.rb +15 -0
- data/lib/overcommit/hook/shared/index_tags.rb +14 -0
- data/lib/overcommit/hook/shared/npm_install.rb +15 -0
- data/lib/overcommit/hook/shared/pronto.rb +21 -0
- data/lib/overcommit/hook/shared/rake_target.rb +26 -0
- data/lib/overcommit/hook/shared/submodule_status.rb +32 -0
- data/lib/overcommit/hook/shared/yarn_install.rb +15 -0
- data/lib/overcommit/hook_context.rb +19 -0
- data/lib/overcommit/hook_context/base.rb +139 -0
- data/lib/overcommit/hook_context/commit_msg.rb +48 -0
- data/lib/overcommit/hook_context/post_checkout.rb +36 -0
- data/lib/overcommit/hook_context/post_commit.rb +33 -0
- data/lib/overcommit/hook_context/post_merge.rb +37 -0
- data/lib/overcommit/hook_context/post_rewrite.rb +49 -0
- data/lib/overcommit/hook_context/pre_commit.rb +212 -0
- data/lib/overcommit/hook_context/pre_push.rb +89 -0
- data/lib/overcommit/hook_context/pre_rebase.rb +38 -0
- data/lib/overcommit/hook_context/prepare_commit_msg.rb +34 -0
- data/lib/overcommit/hook_context/run_all.rb +48 -0
- data/lib/overcommit/hook_loader/base.rb +48 -0
- data/lib/overcommit/hook_loader/built_in_hook_loader.rb +14 -0
- data/lib/overcommit/hook_loader/plugin_hook_loader.rb +102 -0
- data/lib/overcommit/hook_runner.rb +219 -0
- data/lib/overcommit/hook_signer.rb +123 -0
- data/lib/overcommit/installer.rb +193 -0
- data/lib/overcommit/interrupt_handler.rb +91 -0
- data/lib/overcommit/logger.rb +92 -0
- data/lib/overcommit/message_processor.rb +148 -0
- data/lib/overcommit/os.rb +38 -0
- data/lib/overcommit/printer.rb +145 -0
- data/lib/overcommit/subprocess.rb +98 -0
- data/lib/overcommit/utils.rb +309 -0
- data/lib/overcommit/utils/file_utils.rb +71 -0
- data/lib/overcommit/utils/messages_utils.rb +77 -0
- data/lib/overcommit/version.rb +6 -0
- data/libexec/gerrit-change-id +174 -0
- data/libexec/index-tags +17 -0
- data/template-dir/hooks/commit-msg +116 -0
- data/template-dir/hooks/overcommit-hook +116 -0
- data/template-dir/hooks/post-checkout +116 -0
- data/template-dir/hooks/post-commit +116 -0
- data/template-dir/hooks/post-merge +116 -0
- data/template-dir/hooks/post-rewrite +116 -0
- data/template-dir/hooks/pre-commit +116 -0
- data/template-dir/hooks/pre-push +116 -0
- data/template-dir/hooks/pre-rebase +116 -0
- data/template-dir/hooks/prepare-commit-msg +116 -0
- metadata +303 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Overcommit::Hook::CommitMsg
|
|
4
|
+
# Ensures commit message subject lines are followed by a blank line.
|
|
5
|
+
class SingleLineSubject < Base
|
|
6
|
+
def run
|
|
7
|
+
return :pass if empty_message?
|
|
8
|
+
|
|
9
|
+
unless commit_message_lines[1].to_s.strip.empty?
|
|
10
|
+
return :warn, 'Subject should be one line and followed by a blank line'
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
:pass
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'tempfile'
|
|
4
|
+
|
|
5
|
+
module Overcommit::Hook::CommitMsg
|
|
6
|
+
# Checks the commit message for potential misspellings with `hunspell`.
|
|
7
|
+
#
|
|
8
|
+
# @see http://hunspell.sourceforge.net/
|
|
9
|
+
class SpellCheck < Base
|
|
10
|
+
Misspelling = Struct.new(:word, :suggestions)
|
|
11
|
+
|
|
12
|
+
MISSPELLING_REGEX = /^[&#]\s(?<word>\w+)(?:.+?:\s(?<suggestions>.*))?/
|
|
13
|
+
|
|
14
|
+
def run
|
|
15
|
+
result = execute(command + [uncommented_commit_msg_file])
|
|
16
|
+
return [:fail, "Error running spellcheck: #{result.stderr.chomp}"] unless result.success?
|
|
17
|
+
|
|
18
|
+
misspellings = parse_misspellings(result.stdout)
|
|
19
|
+
return :pass if misspellings.empty?
|
|
20
|
+
|
|
21
|
+
messages = misspellings.map do |misspelled|
|
|
22
|
+
msg = "Potential misspelling: #{misspelled.word}."
|
|
23
|
+
msg += " Suggestions: #{misspelled.suggestions}" unless misspelled.suggestions.nil?
|
|
24
|
+
msg
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
[:warn, messages.join("\n")]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
def uncommented_commit_msg_file
|
|
33
|
+
::Tempfile.open('commit-msg') do |file|
|
|
34
|
+
file.write(commit_message)
|
|
35
|
+
file.path
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def parse_misspellings(output)
|
|
40
|
+
output.scan(MISSPELLING_REGEX).map do |word, suggestions|
|
|
41
|
+
Misspelling.new(word, suggestions)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Overcommit::Hook::CommitMsg
|
|
4
|
+
# Ensures the number of columns the subject and commit message lines occupy is
|
|
5
|
+
# under the preferred limits.
|
|
6
|
+
class TextWidth < Base
|
|
7
|
+
def run
|
|
8
|
+
return :pass if empty_message?
|
|
9
|
+
|
|
10
|
+
@errors = []
|
|
11
|
+
|
|
12
|
+
find_errors_in_subject(commit_message_lines.first.chomp)
|
|
13
|
+
find_errors_in_body(commit_message_lines)
|
|
14
|
+
|
|
15
|
+
return :warn, @errors.join("\n") if @errors.any?
|
|
16
|
+
|
|
17
|
+
:pass
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def find_errors_in_subject(subject)
|
|
23
|
+
max_subject_width =
|
|
24
|
+
config['max_subject_width'] +
|
|
25
|
+
special_prefix_length(subject)
|
|
26
|
+
|
|
27
|
+
if subject.length > max_subject_width
|
|
28
|
+
@errors << "Commit message subject must be <= #{max_subject_width} characters"
|
|
29
|
+
return
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
min_subject_width = config['min_subject_width']
|
|
33
|
+
if subject.length < min_subject_width
|
|
34
|
+
@errors << "Commit message subject must be >= #{min_subject_width} characters"
|
|
35
|
+
return
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def find_errors_in_body(lines)
|
|
40
|
+
return unless lines.count > 2
|
|
41
|
+
|
|
42
|
+
max_body_width = config['max_body_width']
|
|
43
|
+
|
|
44
|
+
lines[2..-1].each_with_index do |line, index|
|
|
45
|
+
if line.chomp.size > max_body_width
|
|
46
|
+
@errors << "Line #{index + 3} of commit message has > " \
|
|
47
|
+
"#{max_body_width} characters"
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def special_prefix_length(subject)
|
|
53
|
+
subject.match(/^(fixup|squash)! /) { |match| match[0].length } || 0
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Overcommit::Hook::CommitMsg
|
|
4
|
+
# Ensures commit message subject lines do not have a trailing period
|
|
5
|
+
class TrailingPeriod < Base
|
|
6
|
+
def run
|
|
7
|
+
return :pass if empty_message?
|
|
8
|
+
|
|
9
|
+
if commit_message_lines.first.rstrip.end_with?('.')
|
|
10
|
+
return :warn, 'Please omit trailing period from commit message subject'
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
:pass
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'forwardable'
|
|
4
|
+
|
|
5
|
+
module Overcommit::Hook::PostCheckout
|
|
6
|
+
# Functionality common to all post-checkout hooks.
|
|
7
|
+
class Base < Overcommit::Hook::Base
|
|
8
|
+
extend Forwardable
|
|
9
|
+
|
|
10
|
+
def_delegators :@context,
|
|
11
|
+
:previous_head, :new_head, :branch_checkout?, :file_checkout?
|
|
12
|
+
|
|
13
|
+
def skip_file_checkout?
|
|
14
|
+
@config['skip_file_checkout'] != false
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def enabled?
|
|
18
|
+
return false if file_checkout? && skip_file_checkout?
|
|
19
|
+
super
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'overcommit/hook/shared/bower_install'
|
|
4
|
+
|
|
5
|
+
module Overcommit::Hook::PostCheckout
|
|
6
|
+
# Runs `bower install` when a change is detected in the repository's
|
|
7
|
+
# dependencies.
|
|
8
|
+
#
|
|
9
|
+
# @see Overcommit::Hook::Shared::BowerInstall
|
|
10
|
+
class BowerInstall < Base
|
|
11
|
+
include Overcommit::Hook::Shared::BowerInstall
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'overcommit/hook/shared/bundle_install'
|
|
4
|
+
|
|
5
|
+
module Overcommit::Hook::PostCheckout
|
|
6
|
+
# Runs `bundle install` when a change is detected in the repository's
|
|
7
|
+
# dependencies.
|
|
8
|
+
#
|
|
9
|
+
# @see Overcommit::Hook::Shared::BundleInstall
|
|
10
|
+
class BundleInstall < Base
|
|
11
|
+
include Overcommit::Hook::Shared::BundleInstall
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'overcommit/hook/shared/composer_install'
|
|
4
|
+
|
|
5
|
+
module Overcommit::Hook::PostCheckout
|
|
6
|
+
# Runs `composer install` when a change is detected in the repository's
|
|
7
|
+
# dependencies.
|
|
8
|
+
#
|
|
9
|
+
# @see Overcommit::Hook::Shared::ComposerInstall
|
|
10
|
+
class ComposerInstall < Base
|
|
11
|
+
include Overcommit::Hook::Shared::ComposerInstall
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'overcommit/hook/shared/index_tags'
|
|
4
|
+
|
|
5
|
+
module Overcommit::Hook::PostCheckout
|
|
6
|
+
# Updates ctags index for all source code in the repository.
|
|
7
|
+
#
|
|
8
|
+
# @see Overcommit::Hook::Shared::IndexTags
|
|
9
|
+
class IndexTags < Base
|
|
10
|
+
include Overcommit::Hook::Shared::IndexTags
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'overcommit/hook/shared/npm_install'
|
|
4
|
+
|
|
5
|
+
module Overcommit::Hook::PostCheckout
|
|
6
|
+
# Runs `npm install` when a change is detected in the repository's
|
|
7
|
+
# dependencies.
|
|
8
|
+
#
|
|
9
|
+
# @see Overcommit::Hook::Shared::NpmInstall
|
|
10
|
+
class NpmInstall < Base
|
|
11
|
+
include Overcommit::Hook::Shared::NpmInstall
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'overcommit/hook/shared/submodule_status'
|
|
4
|
+
|
|
5
|
+
module Overcommit::Hook::PostCheckout
|
|
6
|
+
# Checks the status of submodules in the current repository and
|
|
7
|
+
# notifies the user if any are uninitialized, out of date with
|
|
8
|
+
# the current index, or contain merge conflicts.
|
|
9
|
+
class SubmoduleStatus < Base
|
|
10
|
+
include Overcommit::Hook::Shared::SubmoduleStatus
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'overcommit/hook/shared/yarn_install'
|
|
4
|
+
|
|
5
|
+
module Overcommit::Hook::PostCheckout
|
|
6
|
+
# Runs `yarn install` when a change is detected in the repository's
|
|
7
|
+
# dependencies.
|
|
8
|
+
#
|
|
9
|
+
# @see Overcommit::Hook::Shared::YarnInstall
|
|
10
|
+
class YarnInstall < Base
|
|
11
|
+
include Overcommit::Hook::Shared::YarnInstall
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'forwardable'
|
|
4
|
+
|
|
5
|
+
module Overcommit::Hook::PostCommit
|
|
6
|
+
# Functionality common to all post-commit hooks.
|
|
7
|
+
class Base < Overcommit::Hook::Base
|
|
8
|
+
extend Forwardable
|
|
9
|
+
|
|
10
|
+
def_delegators :@context, :modified_lines_in_file, :initial_commit?
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'overcommit/hook/shared/bower_install'
|
|
4
|
+
|
|
5
|
+
module Overcommit::Hook::PostCommit
|
|
6
|
+
# Runs `bower install` when a change is detected in the repository's
|
|
7
|
+
# dependencies.
|
|
8
|
+
#
|
|
9
|
+
# @see Overcommit::Hook::Shared::BowerInstall
|
|
10
|
+
class BowerInstall < Base
|
|
11
|
+
include Overcommit::Hook::Shared::BowerInstall
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'overcommit/hook/shared/bundle_install'
|
|
4
|
+
|
|
5
|
+
module Overcommit::Hook::PostCommit
|
|
6
|
+
# Runs `bundle install` when a change is detected in the repository's
|
|
7
|
+
# dependencies.
|
|
8
|
+
#
|
|
9
|
+
# @see Overcommit::Hook::Shared::BundleInstall
|
|
10
|
+
class BundleInstall < Base
|
|
11
|
+
include Overcommit::Hook::Shared::BundleInstall
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Overcommit::Hook::PostCommit
|
|
4
|
+
# Check that a commit message conforms to a certain style
|
|
5
|
+
#
|
|
6
|
+
# @see https://www.npmjs.com/package/commitplease
|
|
7
|
+
class Commitplease < Base
|
|
8
|
+
def run
|
|
9
|
+
result = execute(command)
|
|
10
|
+
output = result.stderr
|
|
11
|
+
return :pass if result.success? && output.empty?
|
|
12
|
+
|
|
13
|
+
[:fail, output]
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'overcommit/hook/shared/composer_install'
|
|
4
|
+
|
|
5
|
+
module Overcommit::Hook::PostCommit
|
|
6
|
+
# Runs `composer install` when a change is detected in the repository's
|
|
7
|
+
# dependencies.
|
|
8
|
+
#
|
|
9
|
+
# @see Overcommit::Hook::Shared::ComposerInstall
|
|
10
|
+
class ComposerInstall < Base
|
|
11
|
+
include Overcommit::Hook::Shared::ComposerInstall
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Overcommit::Hook::PostCommit
|
|
4
|
+
# Calculates the change in blame since the last revision.
|
|
5
|
+
#
|
|
6
|
+
# @see https://www.npmjs.com/package/git-guilt
|
|
7
|
+
class GitGuilt < Base
|
|
8
|
+
PLUS_MINUS_REGEX = /^(.*?)(?:(\++)|(-+))$/
|
|
9
|
+
GREEN = 32
|
|
10
|
+
RED = 31
|
|
11
|
+
|
|
12
|
+
def run
|
|
13
|
+
return :pass if initial_commit?
|
|
14
|
+
result = execute(command)
|
|
15
|
+
return :fail, result.stderr unless result.success?
|
|
16
|
+
|
|
17
|
+
return :pass if result.stdout.strip.empty?
|
|
18
|
+
|
|
19
|
+
output = []
|
|
20
|
+
result.stdout.scan(PLUS_MINUS_REGEX) do |user, plus, minus|
|
|
21
|
+
plus = color(GREEN, plus)
|
|
22
|
+
minus = color(RED, minus)
|
|
23
|
+
output << "#{user}#{plus}#{minus}"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
[:warn, output.join("\n")]
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
# Returns text wrapped in ANSI escape code necessary to produce a given
|
|
32
|
+
# color/text display.
|
|
33
|
+
#
|
|
34
|
+
# Taken from Overcommit::Logger as a temporary workaround.
|
|
35
|
+
# TODO: expose logger instance to hooks for colorized output
|
|
36
|
+
#
|
|
37
|
+
# @param code [String] ANSI escape code, e.g. '1;33' for "bold yellow"
|
|
38
|
+
# @param str [String] string to wrap
|
|
39
|
+
def color(code, str)
|
|
40
|
+
STDOUT.tty? ? "\033[#{code}m#{str}\033[0m" : str
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'overcommit/hook/shared/index_tags'
|
|
4
|
+
|
|
5
|
+
module Overcommit::Hook::PostCommit
|
|
6
|
+
# Updates ctags index for all source code in the repository.
|
|
7
|
+
#
|
|
8
|
+
# @see Overcommit::Hook::Shared::IndexTags
|
|
9
|
+
class IndexTags < Base
|
|
10
|
+
include Overcommit::Hook::Shared::IndexTags
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'overcommit/hook/shared/npm_install'
|
|
4
|
+
|
|
5
|
+
module Overcommit::Hook::PostCommit
|
|
6
|
+
# Runs `npm install` when a change is detected in the repository's
|
|
7
|
+
# dependencies.
|
|
8
|
+
#
|
|
9
|
+
# @see Overcommit::Hook::Shared::NpmInstall
|
|
10
|
+
class NpmInstall < Base
|
|
11
|
+
include Overcommit::Hook::Shared::NpmInstall
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'overcommit/hook/shared/submodule_status'
|
|
4
|
+
|
|
5
|
+
module Overcommit::Hook::PostCommit
|
|
6
|
+
# Checks the status of submodules in the current repository and
|
|
7
|
+
# notifies the user if any are uninitialized, out of date with
|
|
8
|
+
# the current index, or contain merge conflicts.
|
|
9
|
+
class SubmoduleStatus < Base
|
|
10
|
+
include Overcommit::Hook::Shared::SubmoduleStatus
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'overcommit/hook/shared/yarn_install'
|
|
4
|
+
|
|
5
|
+
module Overcommit::Hook::PostCommit
|
|
6
|
+
# Runs `yarn install` when a change is detected in the repository's
|
|
7
|
+
# dependencies.
|
|
8
|
+
#
|
|
9
|
+
# @see Overcommit::Hook::Shared::YarnInstall
|
|
10
|
+
class YarnInstall < Base
|
|
11
|
+
include Overcommit::Hook::Shared::YarnInstall
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'forwardable'
|
|
4
|
+
|
|
5
|
+
module Overcommit::Hook::PostMerge
|
|
6
|
+
# Functionality common to all post-merge hooks.
|
|
7
|
+
class Base < Overcommit::Hook::Base
|
|
8
|
+
extend Forwardable
|
|
9
|
+
|
|
10
|
+
def_delegators :@context, :modified_lines_in_file, :squash?, :merge_commit?
|
|
11
|
+
end
|
|
12
|
+
end
|