From 6f442e774b9236c999f36c2d7af17640f49bff99 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 9 Apr 2024 15:38:02 +0200 Subject: Adding upstream version 0.19.1. Signed-off-by: Daniel Baumann --- .devcontainer/Dockerfile | 21 + .devcontainer/devcontainer.json | 61 + .devcontainer/postCreateCommand.sh | 24 + .github/ISSUE_TEMPLATE/issue-template.md | 22 + .github/PULL_REQUEST_TEMPLATE.md | 13 + .github/dependabot.yml | 18 + .github/workflows/ci.yml | 142 + .github/workflows/github-release.yml | 14 + .github/workflows/publish-docker.yml | 79 + .github/workflows/publish-release.yml | 176 + .github/workflows/test-release.yml | 95 + .gitignore | 70 + .gitlint | 9 + .pre-commit-hooks.yaml | 16 + CHANGELOG.md | 545 +++ CONTRIBUTING.md | 6 + Dockerfile | 17 + LICENSE | 22 + README.md | 24 + docs/configuration.md | 628 ++++ docs/contrib_rules.md | 83 + docs/contributing.md | 213 ++ docs/demos/asciicinema.json | 3798 ++++++++++++++++++++ docs/demos/scenario.txt | 75 + docs/extra.css | 12 + docs/extra.js | 5 + docs/images/RuleViolation.png | Bin 0 -> 27806 bytes docs/images/RuleViolations.graffle | Bin 0 -> 3291 bytes docs/images/dev-container.png | Bin 0 -> 212226 bytes docs/images/gitlint-packages.drawio.svg | 351 ++ docs/images/gitlint-packages.png | Bin 0 -> 51975 bytes docs/images/readme-gitlint.png | Bin 0 -> 348007 bytes docs/index.md | 506 +++ docs/rules.md | 461 +++ docs/user_defined_rules.md | 415 +++ examples/commit-message-1 | 5 + examples/commit-message-10 | 6 + examples/commit-message-11 | 7 + examples/commit-message-2 | 5 + examples/commit-message-3 | 3 + examples/commit-message-4 | 3 + examples/commit-message-5 | 1 + examples/commit-message-6 | 1 + examples/commit-message-7 | 4 + examples/commit-message-8 | 6 + examples/commit-message-9 | 7 + examples/gitlint | 58 + examples/my_commit_rules.py | 92 + examples/my_configuration_rules.py | 69 + examples/my_line_rules.py | 55 + gitlint-core/LICENSE | 22 + gitlint-core/README.md | 26 + gitlint-core/gitlint/__init__.py | 8 + gitlint-core/gitlint/cache.py | 54 + gitlint-core/gitlint/cli.py | 499 +++ gitlint-core/gitlint/config.py | 561 +++ gitlint-core/gitlint/contrib/__init__.py | 0 gitlint-core/gitlint/contrib/rules/__init__.py | 0 .../gitlint/contrib/rules/authors_commit.py | 45 + .../gitlint/contrib/rules/conventional_commit.py | 37 + .../contrib/rules/disallow_cleanup_commits.py | 22 + gitlint-core/gitlint/contrib/rules/signedoff_by.py | 17 + gitlint-core/gitlint/deprecation.py | 39 + gitlint-core/gitlint/display.py | 36 + gitlint-core/gitlint/exception.py | 2 + gitlint-core/gitlint/files/commit-msg | 35 + gitlint-core/gitlint/files/gitlint | 140 + gitlint-core/gitlint/git.py | 510 +++ gitlint-core/gitlint/hooks.py | 65 + gitlint-core/gitlint/lint.py | 123 + gitlint-core/gitlint/options.py | 146 + gitlint-core/gitlint/rule_finder.py | 155 + gitlint-core/gitlint/rules.py | 485 +++ gitlint-core/gitlint/shell.py | 78 + gitlint-core/gitlint/tests/__init__.py | 0 gitlint-core/gitlint/tests/base.py | 227 ++ gitlint-core/gitlint/tests/cli/test_cli.py | 736 ++++ gitlint-core/gitlint/tests/cli/test_cli_hooks.py | 277 ++ gitlint-core/gitlint/tests/config/test_config.py | 320 ++ .../gitlint/tests/config/test_config_builder.py | 275 ++ .../gitlint/tests/config/test_config_precedence.py | 98 + .../gitlint/tests/config/test_rule_collection.py | 62 + gitlint-core/gitlint/tests/contrib/__init__.py | 0 .../gitlint/tests/contrib/rules/__init__.py | 0 .../tests/contrib/rules/test_authors_commit.py | 105 + .../contrib/rules/test_conventional_commit.py | 82 + .../contrib/rules/test_disallow_cleanup_commits.py | 34 + .../tests/contrib/rules/test_signedoff_by.py | 28 + .../gitlint/tests/contrib/test_contrib_rules.py | 69 + .../tests/expected/cli/test_cli/test_contrib_1 | 2 + .../tests/expected/cli/test_cli/test_debug_1 | 139 + .../expected/cli/test_cli/test_input_stream_1 | 3 + .../cli/test_cli/test_input_stream_debug_1 | 3 + .../cli/test_cli/test_input_stream_debug_2 | 89 + .../tests/expected/cli/test_cli/test_lint_commit_1 | 2 + .../cli/test_cli/test_lint_multiple_commits_1 | 8 + .../test_cli/test_lint_multiple_commits_config_1 | 6 + .../cli/test_cli/test_lint_multiple_commits_csv_1 | 8 + .../cli/test_cli/test_lint_staged_msg_filename_1 | 2 + .../cli/test_cli/test_lint_staged_msg_filename_2 | 93 + .../expected/cli/test_cli/test_lint_staged_stdin_1 | 3 + .../expected/cli/test_cli/test_lint_staged_stdin_2 | 95 + .../tests/expected/cli/test_cli/test_named_rules_1 | 4 + .../tests/expected/cli/test_cli/test_named_rules_2 | 92 + .../cli/test_cli_hooks/test_hook_config_1_stderr | 2 + .../cli/test_cli_hooks/test_hook_config_1_stdout | 5 + .../cli/test_cli_hooks/test_hook_edit_1_stderr | 6 + .../cli/test_cli_hooks/test_hook_edit_1_stdout | 14 + .../test_cli_hooks/test_hook_local_commit_1_stderr | 2 + .../test_cli_hooks/test_hook_local_commit_1_stdout | 4 + .../cli/test_cli_hooks/test_hook_no_1_stderr | 2 + .../cli/test_cli_hooks/test_hook_no_1_stdout | 8 + .../cli/test_cli_hooks/test_hook_no_tty_1_stderr | 2 + .../cli/test_cli_hooks/test_hook_no_tty_1_stdout | 5 + .../test_hook_stdin_no_violations_1_stdout | 2 + .../test_hook_stdin_violations_1_stderr | 2 + .../test_hook_stdin_violations_1_stdout | 5 + .../cli/test_cli_hooks/test_hook_yes_1_stderr | 2 + .../cli/test_cli_hooks/test_hook_yes_1_stdout | 4 + .../cli/test_cli_hooks/test_run_hook_negative_1 | 2 + .../cli/test_cli_hooks/test_run_hook_negative_2 | 2 + gitlint-core/gitlint/tests/git/test_git.py | 121 + gitlint-core/gitlint/tests/git/test_git_commit.py | 825 +++++ gitlint-core/gitlint/tests/git/test_git_context.py | 73 + gitlint-core/gitlint/tests/rules/__init__.py | 0 .../gitlint/tests/rules/test_body_rules.py | 235 ++ .../tests/rules/test_configuration_rules.py | 178 + .../gitlint/tests/rules/test_meta_rules.py | 80 + gitlint-core/gitlint/tests/rules/test_rules.py | 32 + .../gitlint/tests/rules/test_title_rules.py | 200 ++ .../gitlint/tests/rules/test_user_rules.py | 266 ++ .../gitlint/tests/samples/commit_message/fixup | 1 + .../tests/samples/commit_message/fixup_amend | 1 + .../gitlint/tests/samples/commit_message/merge | 3 + .../tests/samples/commit_message/no-violations | 6 + .../gitlint/tests/samples/commit_message/revert | 3 + .../gitlint/tests/samples/commit_message/sample1 | 14 + .../gitlint/tests/samples/commit_message/sample2 | 1 + .../gitlint/tests/samples/commit_message/sample3 | 6 + .../gitlint/tests/samples/commit_message/sample4 | 7 + .../gitlint/tests/samples/commit_message/sample5 | 7 + .../gitlint/tests/samples/commit_message/squash | 3 + gitlint-core/gitlint/tests/samples/config/AUTHORS | 2 + .../gitlint/tests/samples/config/gitlintconfig | 15 + .../tests/samples/config/invalid-option-value | 11 + .../gitlint/tests/samples/config/named-rules | 8 + .../gitlint/tests/samples/config/no-sections | 1 + .../samples/config/nonexisting-general-option | 13 + .../tests/samples/config/nonexisting-option | 11 + .../gitlint/tests/samples/config/nonexisting-rule | 11 + .../tests/samples/user_rules/bogus-file.txt | 2 + .../user_rules/import_exception/invalid_python.py | 2 + .../user_rules/incorrect_linerule/my_line_rule.py | 8 + .../tests/samples/user_rules/my_commit_rules.foo | 16 + .../tests/samples/user_rules/my_commit_rules.py | 25 + .../samples/user_rules/parent_package/__init__.py | 12 + .../user_rules/parent_package/my_commit_rules.py | 10 + gitlint-core/gitlint/tests/test_cache.py | 55 + gitlint-core/gitlint/tests/test_deprecation.py | 26 + gitlint-core/gitlint/tests/test_display.py | 60 + gitlint-core/gitlint/tests/test_hooks.py | 139 + gitlint-core/gitlint/tests/test_lint.py | 296 ++ gitlint-core/gitlint/tests/test_options.py | 240 ++ gitlint-core/gitlint/tests/test_utils.py | 70 + gitlint-core/gitlint/utils.py | 87 + gitlint-core/pyproject.toml | 71 + hatch_build.py | 13 + mkdocs.yml | 23 + pyproject.toml | 203 ++ qa/__init__.py | 0 qa/base.py | 215 ++ qa/expected/test_commits/test_csv_hash_list_1 | 11 + qa/expected/test_commits/test_ignore_commits_1 | 13 + qa/expected/test_commits/test_lint_head_1 | 8 + .../test_commits/test_lint_staged_msg_filename_1 | 97 + qa/expected/test_commits/test_lint_staged_stdin_1 | 99 + qa/expected/test_commits/test_violations_1 | 7 + qa/expected/test_config/test_config_from_env_1 | 104 + qa/expected/test_config/test_config_from_env_2 | 93 + qa/expected/test_config/test_config_from_file_1 | 5 + .../test_config/test_config_from_file_debug_1 | 101 + qa/expected/test_config/test_set_rule_option_1 | 3 + qa/expected/test_config/test_verbosity_1 | 3 + qa/expected/test_config/test_verbosity_2 | 3 + qa/expected/test_contrib/test_contrib_rules_1 | 3 + .../test_contrib/test_contrib_rules_with_config_1 | 3 + qa/expected/test_gitlint/test_commit_binary_file_1 | 95 + qa/expected/test_gitlint/test_msg_filename_1 | 3 + .../test_gitlint/test_msg_filename_no_tty_1 | 3 + qa/expected/test_gitlint/test_violations_1 | 3 + qa/expected/test_named_rules/test_named_rule_1 | 5 + .../test_named_rules/test_named_user_rule_1 | 9 + qa/expected/test_rules/test_ignore_rules_1 | 3 + qa/expected/test_rules/test_ignore_rules_2 | 2 + qa/expected/test_rules/test_match_regex_rules_1 | 2 + qa/expected/test_stdin/test_stdin_file_1 | 3 + qa/expected/test_stdin/test_stdin_pipe_1 | 3 + qa/expected/test_stdin/test_stdin_pipe_empty_1 | 3 + .../test_user_defined_rules_examples_1 | 5 + .../test_user_defined_rules_examples_2 | 5 + .../test_user_defined_rules_examples_with_config_1 | 6 + .../test_user_defined_rules_extra_1 | 9 + qa/samples/config/gitlintconfig | 13 + qa/samples/config/ignore-release-commits | 7 + qa/samples/config/named-rules | 8 + qa/samples/config/named-user-rules | 15 + qa/samples/user_rules/extra/extra_rules.py | 72 + .../user_rules/incorrect_linerule/my_line_rule.py | 8 + qa/shell.py | 118 + qa/test_commits.py | 276 ++ qa/test_config.py | 133 + qa/test_contrib.py | 31 + qa/test_gitlint.py | 267 ++ qa/test_hooks.py | 178 + qa/test_named_rules.py | 23 + qa/test_rules.py | 61 + qa/test_stdin.py | 53 + qa/test_user_defined.py | 57 + qa/utils.py | 48 + tools/changelog.py | 51 + tools/create-test-repo.sh | 35 + tools/stats.sh | 45 + tools/windows/create-test-repo.bat | 37 + tools/windows/run_tests.bat | 15 + 224 files changed, 20249 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100755 .devcontainer/postCreateCommand.sh create mode 100644 .github/ISSUE_TEMPLATE/issue-template.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/github-release.yml create mode 100644 .github/workflows/publish-docker.yml create mode 100644 .github/workflows/publish-release.yml create mode 100644 .github/workflows/test-release.yml create mode 100644 .gitignore create mode 100644 .gitlint create mode 100644 .pre-commit-hooks.yaml create mode 100644 CHANGELOG.md create mode 100644 CONTRIBUTING.md create mode 100644 Dockerfile create mode 100644 LICENSE create mode 100644 README.md create mode 100644 docs/configuration.md create mode 100644 docs/contrib_rules.md create mode 100644 docs/contributing.md create mode 100644 docs/demos/asciicinema.json create mode 100644 docs/demos/scenario.txt create mode 100644 docs/extra.css create mode 100644 docs/extra.js create mode 100644 docs/images/RuleViolation.png create mode 100644 docs/images/RuleViolations.graffle create mode 100644 docs/images/dev-container.png create mode 100644 docs/images/gitlint-packages.drawio.svg create mode 100644 docs/images/gitlint-packages.png create mode 100644 docs/images/readme-gitlint.png create mode 100644 docs/index.md create mode 100644 docs/rules.md create mode 100644 docs/user_defined_rules.md create mode 100644 examples/commit-message-1 create mode 100644 examples/commit-message-10 create mode 100644 examples/commit-message-11 create mode 100644 examples/commit-message-2 create mode 100644 examples/commit-message-3 create mode 100644 examples/commit-message-4 create mode 100644 examples/commit-message-5 create mode 100644 examples/commit-message-6 create mode 100644 examples/commit-message-7 create mode 100644 examples/commit-message-8 create mode 100644 examples/commit-message-9 create mode 100644 examples/gitlint create mode 100644 examples/my_commit_rules.py create mode 100644 examples/my_configuration_rules.py create mode 100644 examples/my_line_rules.py create mode 100644 gitlint-core/LICENSE create mode 100644 gitlint-core/README.md create mode 100644 gitlint-core/gitlint/__init__.py create mode 100644 gitlint-core/gitlint/cache.py create mode 100644 gitlint-core/gitlint/cli.py create mode 100644 gitlint-core/gitlint/config.py create mode 100644 gitlint-core/gitlint/contrib/__init__.py create mode 100644 gitlint-core/gitlint/contrib/rules/__init__.py create mode 100644 gitlint-core/gitlint/contrib/rules/authors_commit.py create mode 100644 gitlint-core/gitlint/contrib/rules/conventional_commit.py create mode 100644 gitlint-core/gitlint/contrib/rules/disallow_cleanup_commits.py create mode 100644 gitlint-core/gitlint/contrib/rules/signedoff_by.py create mode 100644 gitlint-core/gitlint/deprecation.py create mode 100644 gitlint-core/gitlint/display.py create mode 100644 gitlint-core/gitlint/exception.py create mode 100644 gitlint-core/gitlint/files/commit-msg create mode 100644 gitlint-core/gitlint/files/gitlint create mode 100644 gitlint-core/gitlint/git.py create mode 100644 gitlint-core/gitlint/hooks.py create mode 100644 gitlint-core/gitlint/lint.py create mode 100644 gitlint-core/gitlint/options.py create mode 100644 gitlint-core/gitlint/rule_finder.py create mode 100644 gitlint-core/gitlint/rules.py create mode 100644 gitlint-core/gitlint/shell.py create mode 100644 gitlint-core/gitlint/tests/__init__.py create mode 100644 gitlint-core/gitlint/tests/base.py create mode 100644 gitlint-core/gitlint/tests/cli/test_cli.py create mode 100644 gitlint-core/gitlint/tests/cli/test_cli_hooks.py create mode 100644 gitlint-core/gitlint/tests/config/test_config.py create mode 100644 gitlint-core/gitlint/tests/config/test_config_builder.py create mode 100644 gitlint-core/gitlint/tests/config/test_config_precedence.py create mode 100644 gitlint-core/gitlint/tests/config/test_rule_collection.py create mode 100644 gitlint-core/gitlint/tests/contrib/__init__.py create mode 100644 gitlint-core/gitlint/tests/contrib/rules/__init__.py create mode 100644 gitlint-core/gitlint/tests/contrib/rules/test_authors_commit.py create mode 100644 gitlint-core/gitlint/tests/contrib/rules/test_conventional_commit.py create mode 100644 gitlint-core/gitlint/tests/contrib/rules/test_disallow_cleanup_commits.py create mode 100644 gitlint-core/gitlint/tests/contrib/rules/test_signedoff_by.py create mode 100644 gitlint-core/gitlint/tests/contrib/test_contrib_rules.py create mode 100644 gitlint-core/gitlint/tests/expected/cli/test_cli/test_contrib_1 create mode 100644 gitlint-core/gitlint/tests/expected/cli/test_cli/test_debug_1 create mode 100644 gitlint-core/gitlint/tests/expected/cli/test_cli/test_input_stream_1 create mode 100644 gitlint-core/gitlint/tests/expected/cli/test_cli/test_input_stream_debug_1 create mode 100644 gitlint-core/gitlint/tests/expected/cli/test_cli/test_input_stream_debug_2 create mode 100644 gitlint-core/gitlint/tests/expected/cli/test_cli/test_lint_commit_1 create mode 100644 gitlint-core/gitlint/tests/expected/cli/test_cli/test_lint_multiple_commits_1 create mode 100644 gitlint-core/gitlint/tests/expected/cli/test_cli/test_lint_multiple_commits_config_1 create mode 100644 gitlint-core/gitlint/tests/expected/cli/test_cli/test_lint_multiple_commits_csv_1 create mode 100644 gitlint-core/gitlint/tests/expected/cli/test_cli/test_lint_staged_msg_filename_1 create mode 100644 gitlint-core/gitlint/tests/expected/cli/test_cli/test_lint_staged_msg_filename_2 create mode 100644 gitlint-core/gitlint/tests/expected/cli/test_cli/test_lint_staged_stdin_1 create mode 100644 gitlint-core/gitlint/tests/expected/cli/test_cli/test_lint_staged_stdin_2 create mode 100644 gitlint-core/gitlint/tests/expected/cli/test_cli/test_named_rules_1 create mode 100644 gitlint-core/gitlint/tests/expected/cli/test_cli/test_named_rules_2 create mode 100644 gitlint-core/gitlint/tests/expected/cli/test_cli_hooks/test_hook_config_1_stderr create mode 100644 gitlint-core/gitlint/tests/expected/cli/test_cli_hooks/test_hook_config_1_stdout create mode 100644 gitlint-core/gitlint/tests/expected/cli/test_cli_hooks/test_hook_edit_1_stderr create mode 100644 gitlint-core/gitlint/tests/expected/cli/test_cli_hooks/test_hook_edit_1_stdout create mode 100644 gitlint-core/gitlint/tests/expected/cli/test_cli_hooks/test_hook_local_commit_1_stderr create mode 100644 gitlint-core/gitlint/tests/expected/cli/test_cli_hooks/test_hook_local_commit_1_stdout create mode 100644 gitlint-core/gitlint/tests/expected/cli/test_cli_hooks/test_hook_no_1_stderr create mode 100644 gitlint-core/gitlint/tests/expected/cli/test_cli_hooks/test_hook_no_1_stdout create mode 100644 gitlint-core/gitlint/tests/expected/cli/test_cli_hooks/test_hook_no_tty_1_stderr create mode 100644 gitlint-core/gitlint/tests/expected/cli/test_cli_hooks/test_hook_no_tty_1_stdout create mode 100644 gitlint-core/gitlint/tests/expected/cli/test_cli_hooks/test_hook_stdin_no_violations_1_stdout create mode 100644 gitlint-core/gitlint/tests/expected/cli/test_cli_hooks/test_hook_stdin_violations_1_stderr create mode 100644 gitlint-core/gitlint/tests/expected/cli/test_cli_hooks/test_hook_stdin_violations_1_stdout create mode 100644 gitlint-core/gitlint/tests/expected/cli/test_cli_hooks/test_hook_yes_1_stderr create mode 100644 gitlint-core/gitlint/tests/expected/cli/test_cli_hooks/test_hook_yes_1_stdout create mode 100644 gitlint-core/gitlint/tests/expected/cli/test_cli_hooks/test_run_hook_negative_1 create mode 100644 gitlint-core/gitlint/tests/expected/cli/test_cli_hooks/test_run_hook_negative_2 create mode 100644 gitlint-core/gitlint/tests/git/test_git.py create mode 100644 gitlint-core/gitlint/tests/git/test_git_commit.py create mode 100644 gitlint-core/gitlint/tests/git/test_git_context.py create mode 100644 gitlint-core/gitlint/tests/rules/__init__.py create mode 100644 gitlint-core/gitlint/tests/rules/test_body_rules.py create mode 100644 gitlint-core/gitlint/tests/rules/test_configuration_rules.py create mode 100644 gitlint-core/gitlint/tests/rules/test_meta_rules.py create mode 100644 gitlint-core/gitlint/tests/rules/test_rules.py create mode 100644 gitlint-core/gitlint/tests/rules/test_title_rules.py create mode 100644 gitlint-core/gitlint/tests/rules/test_user_rules.py create mode 100644 gitlint-core/gitlint/tests/samples/commit_message/fixup create mode 100644 gitlint-core/gitlint/tests/samples/commit_message/fixup_amend create mode 100644 gitlint-core/gitlint/tests/samples/commit_message/merge create mode 100644 gitlint-core/gitlint/tests/samples/commit_message/no-violations create mode 100644 gitlint-core/gitlint/tests/samples/commit_message/revert create mode 100644 gitlint-core/gitlint/tests/samples/commit_message/sample1 create mode 100644 gitlint-core/gitlint/tests/samples/commit_message/sample2 create mode 100644 gitlint-core/gitlint/tests/samples/commit_message/sample3 create mode 100644 gitlint-core/gitlint/tests/samples/commit_message/sample4 create mode 100644 gitlint-core/gitlint/tests/samples/commit_message/sample5 create mode 100644 gitlint-core/gitlint/tests/samples/commit_message/squash create mode 100644 gitlint-core/gitlint/tests/samples/config/AUTHORS create mode 100644 gitlint-core/gitlint/tests/samples/config/gitlintconfig create mode 100644 gitlint-core/gitlint/tests/samples/config/invalid-option-value create mode 100644 gitlint-core/gitlint/tests/samples/config/named-rules create mode 100644 gitlint-core/gitlint/tests/samples/config/no-sections create mode 100644 gitlint-core/gitlint/tests/samples/config/nonexisting-general-option create mode 100644 gitlint-core/gitlint/tests/samples/config/nonexisting-option create mode 100644 gitlint-core/gitlint/tests/samples/config/nonexisting-rule create mode 100644 gitlint-core/gitlint/tests/samples/user_rules/bogus-file.txt create mode 100644 gitlint-core/gitlint/tests/samples/user_rules/import_exception/invalid_python.py create mode 100644 gitlint-core/gitlint/tests/samples/user_rules/incorrect_linerule/my_line_rule.py create mode 100644 gitlint-core/gitlint/tests/samples/user_rules/my_commit_rules.foo create mode 100644 gitlint-core/gitlint/tests/samples/user_rules/my_commit_rules.py create mode 100644 gitlint-core/gitlint/tests/samples/user_rules/parent_package/__init__.py create mode 100644 gitlint-core/gitlint/tests/samples/user_rules/parent_package/my_commit_rules.py create mode 100644 gitlint-core/gitlint/tests/test_cache.py create mode 100644 gitlint-core/gitlint/tests/test_deprecation.py create mode 100644 gitlint-core/gitlint/tests/test_display.py create mode 100644 gitlint-core/gitlint/tests/test_hooks.py create mode 100644 gitlint-core/gitlint/tests/test_lint.py create mode 100644 gitlint-core/gitlint/tests/test_options.py create mode 100644 gitlint-core/gitlint/tests/test_utils.py create mode 100644 gitlint-core/gitlint/utils.py create mode 100644 gitlint-core/pyproject.toml create mode 100644 hatch_build.py create mode 100644 mkdocs.yml create mode 100644 pyproject.toml create mode 100644 qa/__init__.py create mode 100644 qa/base.py create mode 100644 qa/expected/test_commits/test_csv_hash_list_1 create mode 100644 qa/expected/test_commits/test_ignore_commits_1 create mode 100644 qa/expected/test_commits/test_lint_head_1 create mode 100644 qa/expected/test_commits/test_lint_staged_msg_filename_1 create mode 100644 qa/expected/test_commits/test_lint_staged_stdin_1 create mode 100644 qa/expected/test_commits/test_violations_1 create mode 100644 qa/expected/test_config/test_config_from_env_1 create mode 100644 qa/expected/test_config/test_config_from_env_2 create mode 100644 qa/expected/test_config/test_config_from_file_1 create mode 100644 qa/expected/test_config/test_config_from_file_debug_1 create mode 100644 qa/expected/test_config/test_set_rule_option_1 create mode 100644 qa/expected/test_config/test_verbosity_1 create mode 100644 qa/expected/test_config/test_verbosity_2 create mode 100644 qa/expected/test_contrib/test_contrib_rules_1 create mode 100644 qa/expected/test_contrib/test_contrib_rules_with_config_1 create mode 100644 qa/expected/test_gitlint/test_commit_binary_file_1 create mode 100644 qa/expected/test_gitlint/test_msg_filename_1 create mode 100644 qa/expected/test_gitlint/test_msg_filename_no_tty_1 create mode 100644 qa/expected/test_gitlint/test_violations_1 create mode 100644 qa/expected/test_named_rules/test_named_rule_1 create mode 100644 qa/expected/test_named_rules/test_named_user_rule_1 create mode 100644 qa/expected/test_rules/test_ignore_rules_1 create mode 100644 qa/expected/test_rules/test_ignore_rules_2 create mode 100644 qa/expected/test_rules/test_match_regex_rules_1 create mode 100644 qa/expected/test_stdin/test_stdin_file_1 create mode 100644 qa/expected/test_stdin/test_stdin_pipe_1 create mode 100644 qa/expected/test_stdin/test_stdin_pipe_empty_1 create mode 100644 qa/expected/test_user_defined/test_user_defined_rules_examples_1 create mode 100644 qa/expected/test_user_defined/test_user_defined_rules_examples_2 create mode 100644 qa/expected/test_user_defined/test_user_defined_rules_examples_with_config_1 create mode 100644 qa/expected/test_user_defined/test_user_defined_rules_extra_1 create mode 100644 qa/samples/config/gitlintconfig create mode 100644 qa/samples/config/ignore-release-commits create mode 100644 qa/samples/config/named-rules create mode 100644 qa/samples/config/named-user-rules create mode 100644 qa/samples/user_rules/extra/extra_rules.py create mode 100644 qa/samples/user_rules/incorrect_linerule/my_line_rule.py create mode 100644 qa/shell.py create mode 100644 qa/test_commits.py create mode 100644 qa/test_config.py create mode 100644 qa/test_contrib.py create mode 100644 qa/test_gitlint.py create mode 100644 qa/test_hooks.py create mode 100644 qa/test_named_rules.py create mode 100644 qa/test_rules.py create mode 100644 qa/test_stdin.py create mode 100644 qa/test_user_defined.py create mode 100644 qa/utils.py create mode 100755 tools/changelog.py create mode 100755 tools/create-test-repo.sh create mode 100755 tools/stats.sh create mode 100644 tools/windows/create-test-repo.bat create mode 100644 tools/windows/run_tests.bat diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..b429c19 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,21 @@ +# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/python-3/.devcontainer/base.Dockerfile + +# [Choice] Python version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.10, 3.9, 3.8, 3.7, 3.6, 3-bullseye, 3.10-bullseye, 3.9-bullseye, 3.8-bullseye, 3.7-bullseye, 3.6-bullseye, 3-buster, 3.10-buster, 3.9-buster, 3.8-buster, 3.7-buster, 3.6-buster +ARG VARIANT="3.10-bullseye" +FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT} + +# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10 +ARG NODE_VERSION="none" +RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi + +# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image. +# COPY requirements.txt /tmp/pip-tmp/ +# RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \ +# && rm -rf /tmp/pip-tmp + +# [Optional] Uncomment this section to install additional OS packages. +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends + +# [Optional] Uncomment this line to install global node packages. +# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g " 2>&1 \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..65fcc1c --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,61 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/python-3 +{ + "name": "Python 3", + "build": { + "dockerfile": "Dockerfile", + "context": "..", + "args": { + // Update 'VARIANT' to pick a Python version: 3, 3.10, 3.9, 3.8, 3.7, 3.6 + // Append -bullseye or -buster to pin to an OS version. + // Use -bullseye variants on local on arm64/Apple Silicon. + "VARIANT": "3.10", + // Options + "NODE_VERSION": "none" + } + }, + // Configure tool-specific properties. + "customizations": { + // Configure properties specific to VS Code. + "vscode": { + // Set *default* container specific settings.json values on container create. + "settings": { + "python.defaultInterpreterPath": "/usr/local/bin/python", + "python.linting.enabled": true, + "python.formatting.provider": "black", + "python.formatting.blackArgs": [ + "--config", + "./pyproject.toml" + ], + "python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8", + "python.formatting.blackPath": "/usr/local/py-utils/bin/black", + "python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf", + "python.linting.banditPath": "/usr/local/py-utils/bin/bandit", + "python.linting.flake8Path": "/usr/local/py-utils/bin/flake8", + "python.linting.mypyPath": "/usr/local/py-utils/bin/mypy", + "python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle", + "python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle", + }, + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "ms-python.python", + "ms-python.vscode-pylance", + "charliermarsh.ruff", + "tamasfe.even-better-toml" + ] + } + }, + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "pip3 install --user -r requirements.txt", + // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "vscode", + "features": { + "git": "latest", + "github-cli": "latest", + "sshd": "latest", + "homebrew": "latest" + }, + "postCreateCommand": "./.devcontainer/postCreateCommand.sh" +} \ No newline at end of file diff --git a/.devcontainer/postCreateCommand.sh b/.devcontainer/postCreateCommand.sh new file mode 100755 index 0000000..e2f0f76 --- /dev/null +++ b/.devcontainer/postCreateCommand.sh @@ -0,0 +1,24 @@ +#!/bin/sh -x + +brew install asdf +brew install hatch +source "$(brew --prefix asdf)/libexec/asdf.sh" + +# Install latest python +asdf plugin add python +asdf install python 3.11.0 +asdf global python 3.11.0 + +# You can easily install other python versions like so: +# asdf install python 3.6.15 +# asdf install python 3.7.15 +# asdf install python 3.8.15 +# asdf install python 3.9.15 +# asdf install python 3.10.8 +# asdf install python pypy3.9-7.3.9 + +# Setup virtualenv, install all dependencies +cd /workspaces/gitlint +$(asdf which python) -m venv .venv +source .venv/bin/activate +pip install -r requirements.txt -r test-requirements.txt -r doc-requirements.txt \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/issue-template.md b/.github/ISSUE_TEMPLATE/issue-template.md new file mode 100644 index 0000000..c178614 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/issue-template.md @@ -0,0 +1,22 @@ +--- +name: Issue template +about: Bug reports, feature requests +title: '' +labels: '' +assignees: '' + +--- + + + +Enter your issue details here diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..db7f144 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,13 @@ + + +Enter your PR details here diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..a781b54 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,18 @@ +version: 2 +updates: + - package-ecosystem: docker + directory: / + schedule: + interval: daily + - package-ecosystem: github-actions + directory: / + schedule: + interval: daily + - package-ecosystem: pip + directory: / + schedule: + interval: daily + - package-ecosystem: pip + directory: /gitlint-core + schedule: + interval: daily diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..403dcc4 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,142 @@ +name: Tests and Checks + +# Only run CI on pushes to main and pull requests +# We don't run CI on other branches, but those should be merged into main via a PR anyways which will trigger CI before the merge. +on: + push: + branches: + - main + pull_request: + branches: + - main + +concurrency: + group: ci-${{ github.ref }}-1 + cancel-in-progress: true + +jobs: + checks: + runs-on: "ubuntu-latest" + strategy: + matrix: + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", pypy-3.9] + os: ["macos-latest", "ubuntu-latest", "windows-latest"] + steps: + - uses: actions/checkout@v3.3.0 + with: + ref: ${{ github.event.pull_request.head.sha }} # Checkout pull request HEAD commit instead of merge commit + fetch-depth: 0 # checkout all history, needed for hatch versioning + + - name: Setup python + uses: actions/setup-python@v4.5.0 + with: + python-version: ${{ matrix.python-version }} + + - name: Install pypa/build + run: python -m pip install build==0.10.0 + + - name: Install Hatch + run: python -m pip install hatch==1.6.3 + + - name: Unit Tests + run: hatch run test:unit-tests + + - name: Code formatting (black) + run: hatch run test:format + + - name: Code linting (ruff) + run: hatch run test:lint + + - name: Install local gitlint for integration tests + run: | + hatch run qa:install-local + + - name: Integration tests (default -> GITLINT_USE_SH_LIB=1) + run: | + hatch run qa:integration-tests + if: matrix.os != 'windows-latest' + + - name: Integration tests (GITLINT_USE_SH_LIB=1) + run: | + hatch run qa:integration-tests + env: + GITLINT_USE_SH_LIB: 1 + if: matrix.os != 'windows-latest' + + - name: Integration tests (GITLINT_QA_USE_SH_LIB=0) + run: | + hatch run qa:integration-tests -k "not(test_commit_hook_continue or test_commit_hook_abort or test_commit_hook_edit)" qa + env: + GITLINT_QA_USE_SH_LIB: 0 + if: matrix.os != 'windows-latest' + + - name: Integration tests (Windows) + run: | + hatch run qa:integration-tests -k "not (test_commit_hook_continue or test_commit_hook_abort or test_commit_hook_edit or test_lint_staged_stdin or test_stdin_file or test_stdin_pipe_empty)" qa + if: matrix.os == 'windows-latest' + + - name: Build test (gitlint) + run: | + python -m build + hatch clean + + - name: Build test (gitlint-core) + run: | + python -m build + hatch clean + working-directory: ./gitlint-core + + - name: Docs build (mkdocs) + run: hatch run docs:build + + # Run gitlint. Skip during PR runs, since PR commit messages are transient and usually full of gitlint violations. + # PRs get squashed and get a proper commit message during merge. + - name: gitlint --debug + run: hatch run dev:gitlint --debug + continue-on-error: ${{ github.event_name == 'pull_request' }} # Don't enforce gitlint in PRs + + - name: Code Coverage (coveralls) + uses: coverallsapp/github-action@master + with: + path-to-lcov: ".coverage.lcov" + github-token: ${{ secrets.GITHUB_TOKEN }} + git-commit: ${{ github.event.pull_request.head.sha }} + flag-name: gitlint-${{ matrix.os }}-${{ matrix.python-version }} + parallel: true + + upload_coveralls: + needs: checks + runs-on: ubuntu-latest + steps: + - name: Upload coverage to coveralls + uses: coverallsapp/github-action@master + with: + path-to-lcov: ".coverage.lcov" + github-token: ${{ secrets.GITHUB_TOKEN }} + parallel-finished: true + + check: # This job does nothing and is only used for the branch protection + if: always() # Ref: https://github.com/marketplace/actions/alls-green#why + + needs: + - upload_coveralls + - checks + + runs-on: ubuntu-latest + + steps: + - name: Decide whether the needed jobs succeeded or failed + uses: re-actors/alls-green@release/v1 + with: + jobs: ${{ toJSON(needs) }} + + # When on main, auto publish dev build + auto-publish-dev: + needs: + - check + if: github.ref == 'refs/heads/main' + uses: ./.github/workflows/publish-release.yml + secrets: inherit # pass all secrets (required to access secrets in a called workflow) + with: + pypi_target: "pypi.org" + repo_release_ref: "main" diff --git a/.github/workflows/github-release.yml b/.github/workflows/github-release.yml new file mode 100644 index 0000000..e5e40c9 --- /dev/null +++ b/.github/workflows/github-release.yml @@ -0,0 +1,14 @@ +name: Github Release Publish +run-name: "Github Release Publish (tag=${{github.ref_name}})" + +on: + release: + types: [published] + +jobs: + publish-release: + uses: ./.github/workflows/publish-release.yml + secrets: inherit # pass all secrets (required to access secrets in a called workflow) + with: + pypi_target: "pypi.org" + repo_release_ref: ${{ github.ref_name }} diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml new file mode 100644 index 0000000..092b6b3 --- /dev/null +++ b/.github/workflows/publish-docker.yml @@ -0,0 +1,79 @@ +name: Publish Docker +run-name: "Publish Docker (gitlint_version=${{ inputs.gitlint_version }})" + +on: + workflow_call: + inputs: + gitlint_version: + description: "Gitlint version to build docker image for" + required: true + type: string + docker_image_tag: + description: "Docker image tag" + required: true + type: string + push_to_dockerhub: + description: "Push to dockerhub.com" + required: false + type: boolean + default: false + workflow_dispatch: + inputs: + gitlint_version: + description: "Gitlint version to build docker image for" + type: string + docker_image_tag: + description: "Docker image tag" + required: true + type: choice + options: + - "latest_dev" + - "latest" + - "Use $gitlint_version" + default: "Use $gitlint_version" + push_to_dockerhub: + description: "Push to dockerhub.com" + required: false + type: boolean + default: false + +jobs: + publish_docker: + runs-on: "ubuntu-latest" + steps: + - name: Determine docker tag + id: set_tag + run: | + if [[ "${{ inputs.docker_image_tag }}" == "Use $gitlint_version" ]]; then + echo "docker_image_tag=${{ inputs.gitlint_version }}" >> $GITHUB_OUTPUT + else + echo "docker_image_tag=${{ inputs.docker_image_tag }}" >> $GITHUB_OUTPUT + fi + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: jorisroovers + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build docker image + uses: docker/build-push-action@v4 + with: + build-args: GITLINT_VERSION=${{ inputs.gitlint_version }} + tags: jorisroovers/gitlint:${{ steps.set_tag.outputs.docker_image_tag }} + + - name: Test docker image + run: | + gitlint_version=$(docker run --ulimit nofile=1024 -v $(pwd):/repo jorisroovers/gitlint:${{ steps.set_tag.outputs.docker_image_tag }} --version) + [ "$gitlint_version" == "gitlint, version ${{ inputs.gitlint_version }}" ] + + + # This won't actually rebuild the docker image, but just push the previously built and cached image + - name: Push docker image + uses: docker/build-push-action@v4 + with: + push: ${{ inputs.push_to_dockerhub }} + build-args: GITLINT_VERSION=${{ inputs.gitlint_version }} + tags: jorisroovers/gitlint:${{ steps.set_tag.outputs.docker_image_tag }} + if: inputs.push_to_dockerhub + \ No newline at end of file diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml new file mode 100644 index 0000000..22ac4be --- /dev/null +++ b/.github/workflows/publish-release.yml @@ -0,0 +1,176 @@ +name: Publish Release +run-name: "Publish Release (pypi_target=${{ inputs.pypi_target }}, repo_release_ref=${{ inputs.repo_release_ref }})" + +on: + # Trigger release workflow from other workflows (e.g. release dev build as part of CI) + workflow_call: + inputs: + pypi_target: + description: "PyPI repository to publish to" + required: true + type: string + default: "test.pypi.org" + repo_release_ref: + description: "Gitlint git reference to publish release for" + type: string + default: "main" + + # Manually trigger a release + workflow_dispatch: + inputs: + pypi_target: + description: "PyPI repository to publish to" + required: true + type: choice + options: + - "pypi.org" + - "test.pypi.org" + default: "test.pypi.org" + repo_release_ref: + description: "Gitlint git reference to publish release for" + type: string + default: "main" + +jobs: + publish: + timeout-minutes: 15 + runs-on: "ubuntu-latest" + outputs: + gitlint_version: ${{ steps.set_version.outputs.gitlint_version }} + steps: + - name: Setup python + uses: actions/setup-python@v4.5.0 + with: + python-version: "3.11" + + - name: Install pypa/build + run: python -m pip install build==0.10.0 + + - name: Install Hatch + run: python -m pip install hatch==1.6.3 + + - uses: actions/checkout@v3.3.0 + with: + ref: ${{ inputs.repo_release_ref }} + fetch-depth: 0 # checkout all history, needed for hatch versioning + + # Run hatch version once to avoid additional output ("Setting up build environment for missing dependencies") + # during the next step + - name: Hatch version + run: hatch version + + # Hatch versioning is based on git (using hatch-vcs). If there is no explicit tag for the commit we're trying to + # publish, hatch versioning strings will have this format: 0.19.0.dev52+g9f7dc7d + # With the string after '+' being the 'g' of the commit. + # + # However, PyPI doesn't allow '+' in version numbers (no PEP440 local versions allowed on PyPI). + # To work around this, we override the version string by setting the SETUPTOOLS_SCM_PRETEND_VERSION env var + # to the version string without the '+' and everything after it. + # We do this by setting the `gitlint_version` step output here and re-using it later to + # set SETUPTOOLS_SCM_PRETEND_VERSION. + # + # We only actually publish such releases on the main branch to guarantee the dev numbering scheme remains + # unique. + # Note that when a tag *is* present (i.e. v0.19.0), hatch versioning will return the tag name (i.e. 0.19.0) + # and this step has no effect, ie. SETUPTOOLS_SCM_PRETEND_VERSION will be the same as `hatch version`. + - name: Set SETUPTOOLS_SCM_PRETEND_VERSION + id: set_version + run: | + echo "gitlint_version=$(hatch version | cut -d+ -f1)" >> $GITHUB_OUTPUT + + - name: Build (gitlint-core) + run: python -m build + working-directory: ./gitlint-core + env: + SETUPTOOLS_SCM_PRETEND_VERSION: ${{ steps.set_version.outputs.gitlint_version }} + + - name: Build (gitlint) + run: python -m build + env: + SETUPTOOLS_SCM_PRETEND_VERSION: ${{ steps.set_version.outputs.gitlint_version }} + + - name: Publish gitlint-core (pypi.org) + run: hatch publish + working-directory: ./gitlint-core + env: + HATCH_INDEX_USER: ${{ secrets.PYPI_GITLINT_CORE_USERNAME }} + HATCH_INDEX_AUTH: ${{ secrets.PYPI_GITLINT_CORE_PASSWORD }} + if: inputs.pypi_target == 'pypi.org' + + - name: Publish gitlint (pypi.org) + run: hatch publish + env: + HATCH_INDEX_USER: ${{ secrets.PYPI_GITLINT_USERNAME }} + HATCH_INDEX_AUTH: ${{ secrets.PYPI_GITLINT_PASSWORD }} + if: inputs.pypi_target == 'pypi.org' + + - name: Publish gitlint-core (test.pypi.org) + run: hatch publish -r test + working-directory: ./gitlint-core + env: + HATCH_INDEX_USER: ${{ secrets.TEST_PYPI_GITLINT_CORE_USERNAME }} + HATCH_INDEX_AUTH: ${{ secrets.TEST_PYPI_GITLINT_CORE_PASSWORD }} + if: inputs.pypi_target == 'test.pypi.org' + + - name: Publish gitlint (test.pypi.org) + run: hatch publish -r test + env: + HATCH_INDEX_USER: ${{ secrets.TEST_PYPI_GITLINT_USERNAME }} + HATCH_INDEX_AUTH: ${{ secrets.TEST_PYPI_GITLINT_PASSWORD }} + if: inputs.pypi_target == 'test.pypi.org' + + # Wait for gitlint package to be available in PyPI for installation + wait-for-package: + needs: + - publish + runs-on: "ubuntu-latest" + steps: + - name: Install gitlint + uses: nick-fields/retry@v2.8.3 + with: + timeout_minutes: 1 + max_attempts: 10 + command: | + python -m pip install gitlint==${{ needs.publish.outputs.gitlint_version }} + if: inputs.pypi_target == 'pypi.org' + + - name: Install gitlint (test.pypi.org) + uses: nick-fields/retry@v2.8.3 + with: + timeout_minutes: 1 + max_attempts: 10 + command: | + pip install --no-cache-dir -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple gitlint==${{ needs.publish.outputs.gitlint_version }} + if: inputs.pypi_target == 'test.pypi.org' + + - name: gitlint --version + run: | + gitlint --version + [ "$(gitlint --version)" == "gitlint, version ${{ needs.publish.outputs.gitlint_version }}" ] + + # Unfortunately, it's not because the newly published package installation worked once that replication + # has finished amongst all PyPI servers (subsequent installations might still fail). We sleep for 10 min here + # to increase the odds that replication has finished. + - name: Sleep + run: sleep 600 + + test-release: + needs: + - publish + - wait-for-package + uses: ./.github/workflows/test-release.yml + with: + gitlint_version: ${{ needs.publish.outputs.gitlint_version }} + pypi_source: ${{ inputs.pypi_target }} + repo_test_ref: ${{ inputs.repo_release_ref }} + + publish-docker: + needs: + - publish + - test-release + uses: ./.github/workflows/publish-docker.yml + secrets: inherit # pass all secrets (required to access secrets in a called workflow) + with: + gitlint_version: ${{ needs.publish.outputs.gitlint_version }} + docker_image_tag: "latest_dev" + push_to_dockerhub: true diff --git a/.github/workflows/test-release.yml b/.github/workflows/test-release.yml new file mode 100644 index 0000000..caf00dd --- /dev/null +++ b/.github/workflows/test-release.yml @@ -0,0 +1,95 @@ +name: Test Release +run-name: "Test Release (${{ inputs.gitlint_version }}, pypi_source=${{ inputs.pypi_source }}, repo_test_ref=${{ inputs.repo_test_ref }})" +on: + workflow_call: + inputs: + gitlint_version: + description: "Gitlint version to test" + required: true + default: "0.18.0" + type: string + pypi_source: + description: "PyPI repository to use" + required: true + type: string + repo_test_ref: + description: "Git reference to checkout for integration tests" + default: "main" + type: string + workflow_dispatch: + inputs: + gitlint_version: + description: "Gitlint version to test" + required: true + default: "0.18.0" + pypi_source: + description: "PyPI repository to use" + required: true + type: choice + options: + - "pypi.org" + - "test.pypi.org" + default: "pypi.org" + repo_test_ref: + description: "Git reference to checkout for integration tests" + default: "main" + +jobs: + test-release: + timeout-minutes: 10 + runs-on: "ubuntu-latest" + strategy: + matrix: + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", pypy-3.9] + os: ["macos-latest", "ubuntu-latest", "windows-latest"] + steps: + - name: Setup python + uses: actions/setup-python@v4.5.0 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Hatch + run: python -m pip install hatch==1.6.3 + + - name: Install gitlint + run: | + python -m pip install gitlint==${{ inputs.gitlint_version }} + if: inputs.pypi_source == 'pypi.org' + + - name: Install gitlint (test.pypi.org) + run: | + pip install --no-cache-dir -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple gitlint==${{ inputs.gitlint_version }} + if: inputs.pypi_source == 'test.pypi.org' + + - name: gitlint --version + run: | + gitlint --version + [ "$(gitlint --version)" == "gitlint, version ${{ inputs.gitlint_version }}" ] + + - uses: actions/checkout@v3.3.0 + with: + ref: ${{ inputs.repo_test_ref }} + + - name: Integration tests (default -> GITLINT_USE_SH_LIB=1) + run: | + hatch run qa:integration-tests + if: matrix.os != 'windows-latest' + + - name: Integration tests (GITLINT_USE_SH_LIB=1) + run: | + hatch run qa:integration-tests + env: + GITLINT_USE_SH_LIB: 1 + if: matrix.os != 'windows-latest' + + - name: Integration tests (GITLINT_QA_USE_SH_LIB=0) + run: | + hatch run qa:integration-tests -k "not(test_commit_hook_continue or test_commit_hook_abort or test_commit_hook_edit)" qa + env: + GITLINT_QA_USE_SH_LIB: 0 + if: matrix.os != 'windows-latest' + + - name: Integration tests (Windows) + run: | + hatch run qa:integration-tests -k "not (test_commit_hook_continue or test_commit_hook_abort or test_commit_hook_edit or test_lint_staged_stdin or test_stdin_file or test_stdin_pipe_empty)" qa + if: matrix.os == 'windows-latest' diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e81c924 --- /dev/null +++ b/.gitignore @@ -0,0 +1,70 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg +.pytest_cache + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +.venv* +virtualenv + +# Vagrant +.vagrant + +# mkdocs +site/ + +# pyenv +.python-version \ No newline at end of file diff --git a/.gitlint b/.gitlint new file mode 100644 index 0000000..011b0a3 --- /dev/null +++ b/.gitlint @@ -0,0 +1,9 @@ +[general] +# See https://jorisroovers.com/gitlint/configuration/#regex-style-search +regex-style-search=True + +# Dependabot tends to generate lines that exceed the default 80 char limit. +[ignore-by-author-name] +regex=dependabot +ignore=all + diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml new file mode 100644 index 0000000..24fd745 --- /dev/null +++ b/.pre-commit-hooks.yaml @@ -0,0 +1,16 @@ +- id: gitlint + name: gitlint + description: Checks your git commit messages for style. + language: python + additional_dependencies: ["./gitlint-core[trusted-deps]"] + entry: gitlint + args: [--staged, --msg-filename] + stages: [commit-msg] +- id: gitlint-ci + name: gitlint + language: python + additional_dependencies: ["./gitlint-core[trusted-deps]"] + entry: gitlint + always_run: true + pass_filenames: false + stages: [manual] diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..f26f670 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,545 @@ +# Changelog + +This file documents notable changes introduced in gitlint releases. + +# v0.20.0 (Unreleased) + +# v0.19.1 (2023-03-10) + +## Development +- Fix issue that prevented homebrew packages from being built ([#460](https://github.com/jorisroovers/gitlint/issues/460)) +- Switch to using pypa/build in CI ([#463](https://github.com/jorisroovers/gitlint/issues/463)) - thanks @webknjaz + + +# v0.19.0 (2023-03-07) + +This release was primarily focussed on modernizing gitlint's build and test tooling (details: [#378](https://github.com/jorisroovers/gitlint/issues/378)). + +## General + - Python 3.6 no longer supported ([EOL since 2021-12-23](https://endoflife.date/python)) ([#379](https://github.com/jorisroovers/gitlint/issues/379)) + - This is the last release to support the [sh](https://amoffat.github.io/sh/) library (used under-the-hood to execute git commands) by setting `GITLINT_USE_SH_LIB=1`. This is already disabled by default since v0.18.0. + +## Features + - Allow for a single commit in the `--commits` cmd-line param ([#412](https://github.com/jorisroovers/gitlint/issues/412)) - thanks [carlescufi](https://github.com/carlescufi) + - Gitlint now separates `FILE_ENCODING` (always UTF-8) from `TERMINAL_ENCODING` (terminal dependent), this should improve issues with unicode. Use `gitlint --debug` to inspect these values. ([#424](https://github.com/jorisroovers/gitlint/issues/424)) + +## Bugfixes + - `ignore-by-author-name` crashes without --staged ([#445](https://github.com/jorisroovers/gitlint/issues/445)) + - Various documentation fixes ([#401](https://github.com/jorisroovers/gitlint/issues/401), [#433](https://github.com/jorisroovers/gitlint/issues/433)) - Thanks [scop](https://github.com/scop) + +## Development + - Adopted [hatch](https://hatch.pypa.io/latest/) for project management ([#384](https://github.com/jorisroovers/gitlint/issues/384)). + This significantly improves the developer workflow, please read the updated [CONTRIBUTING](https://jorisroovers.com/gitlint/contributing/) page. + - Adopted [ruff](https://github.com/charliermarsh/ruff) for linting, replacing pylint ([#404](https://github.com/jorisroovers/gitlint/issues/404)) + - Gitlint now publishes [dev builds on every commit to main](https://jorisroovers.github.io/gitlint/contributing/#dev-builds) ([#429](https://github.com/jorisroovers/gitlint/issues/429)) + - Gitlint now publishes a [`latest_dev` docker image](https://hub.docker.com/r/jorisroovers/gitlint/tags?name=latest_dev) on every commit to main ([#451](https://github.com/jorisroovers/gitlint/issues/452)) ([#452](https://github.com/jorisroovers/gitlint/issues/451)) + - Dependencies updated + - Many improvements to the [CI/CD worfklows](https://github.com/jorisroovers/gitlint/tree/main/.github/workflows) + - Fixed coveralls integration: [coveralls.io/github/jorisroovers/gitlint](https://coveralls.io/github/jorisroovers/gitlint) + - Improve unit test coverage ([#453](https://github.com/jorisroovers/gitlint/issues/453)) + - Integration test fixes on windows ([#392](https://github.com/jorisroovers/gitlint/issues/392), [#397](https://github.com/jorisroovers/gitlint/issues/397)) + - Devcontainer improvements ([#428](https://github.com/jorisroovers/gitlint/issues/428)) + - Removal of Dockerfile.dev ([#390](https://github.com/jorisroovers/gitlint/issues/390)) + - Fix most integration tests on Windows + - Fix Windows unit tests ([#383](https://github.com/jorisroovers/gitlint/issues/383)) + - Introduce a gate/check GHA job ([#375](https://github.com/jorisroovers/gitlint/issues/375)) - Thanks [webknjaz](https://github.com/webknjaz) + - Thanks to [sigmavirus24](https://github.com/sigmavirus24) for continued overall help and support + + +# v0.18.0 (2022-11-16) +Contributors: +Special thanks to all contributors for this release - details inline! + +## General +- Python 3.11 support +- Last release to support Python 3.6 ([EOL since 2021-12-23](https://endoflife.date/python)) +- **Behavior Change**: In a future release, gitlint will be switching to use `re.search` instead of `re.match` semantics for all rules. Your rule regexes might need updating as a result, gitlint will print a warning if so. [More details are in the docs](https://jorisroovers.com/gitlint/configuration/#regex-style-search). ([#254](https://github.com/jorisroovers/gitlint/issues/254)) +- gitlint no longer uses the [sh](https://amoffat.github.io/sh/) library by default in an attempt to reduce external dependencies. In case of issues, the use of `sh` can be re-enabled by setting the env var `GITLINT_USE_SH_LIB=1`. This fallback will be removed entirely in a future gitlint release. ([#351](https://github.com/jorisroovers/gitlint/issues/351)) + +## Features +- `--commits` now also accepts a comma-separated list of commit hashes, making it possible to lint a list of non-contiguous commits without invoking gitlint multiple times ([#283](https://github.com/jorisroovers/gitlint/issues/283)) +- Improved handling of branches that have no commits ([#188](https://github.com/jorisroovers/gitlint/issues/189)) - thanks [domsekotill](https://github.com/domsekotill) +- Support for `GITLINT_CONFIG` env variable ([#189](https://github.com/jorisroovers/gitlint/issues/188)) - thanks [Notgnoshi](https://github.com/Notgnoshi) +- Added [a new `gitlint-ci` pre-commit hook](https://jorisroovers.com/gitlint/#gitlint-and-pre-commit-in-ci), making it easier to run gitlint through pre-commit in CI ([#191](https://github.com/jorisroovers/gitlint/issues/191)) - thanks [guillaumelambert](https://github.com/guillaumelambert) + +## Contrib Rules + - New [contrib-disallow-cleanup-commits](https://jorisroovers.com/gitlint/contrib_rules/#cc2-contrib-disallow-cleanup-commits) rule ([#312](https://github.com/jorisroovers/gitlint/issues/312)) - thanks [matthiasbeyer](https://github.com/matthiasbeyer) + - New [contrib-allowed-authors](https://jorisroovers.com/gitlint/contrib_rules/#cc3-contrib-allowed-authors) rule ([#358](https://github.com/jorisroovers/gitlint/issues/358)) - thanks [stauchert](https://github.com/stauchert) + +## User Defined rules + - Gitlint now recognizes `fixup=amend` commits (see related [git documentation](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---fixupamendrewordltcommitgt)), available as `commit.is_fixup_amend_commit=True` + - Gitlint now parses diff **stat** information, available in `commit.changed_files_stats` ([#314](https://github.com/jorisroovers/gitlint/issues/314)) + +## Bugfixes + - Use correct encoding when using `--msg-filename` parameter ([#310](https://github.com/jorisroovers/gitlint/issues/310)) + - Various documentation fixes ([#244](https://github.com/jorisroovers/gitlint/issues/244)) ([#263](https://github.com/jorisroovers/gitlint/issues/263)) ([#266](https://github.com/jorisroovers/gitlint/issues/266)) ([#294](https://github.com/jorisroovers/gitlint/issues/294)) ([#295](https://github.com/jorisroovers/gitlint/issues/295)) ([#347](https://github.com/jorisroovers/gitlint/issues/347)) ([#364](https://github.com/jorisroovers/gitlint/issues/364)) - thanks [scop](https://github.com/scop), [OrBin](https://github.com/OrBin), [jtaylor100](https://github.com/jtaylor100), [stauchert](https://github.com/stauchert) + +## Development + - Dependencies updated + - Moved to [black](https://github.com/psf/black) for formatting + - Fixed nasty CI issue ([#298](https://github.com/jorisroovers/gitlint/issues/298)) + - Unit tests fix ([#256](https://github.com/jorisroovers/gitlint/issues/256)) - thanks [carlsmedstad](https://github.com/carlsmedstad) + - Vagrant box removed in favor of github dev containers ([#348](https://github.com/jorisroovers/gitlint/issues/348)) + - Removed a few lingering references to the `master` branch in favor of `main` + - Moved [roadmap and project planning](https://github.com/users/jorisroovers/projects/1) to github projects + - Thanks to [sigmavirus24](https://github.com/sigmavirus24) for continued overall help and support + +# v0.17.0 (2021-11-28) +Contributors: +Special thanks to all contributors for this release, in particular [andersk](https://github.com/andersk) and [sigmavirus24](https://github.com/sigmavirus24). + +## General +- Gitlint is now split in 2 packages: `gitlint` and `gitlint-core`. This allows users to install gitlint without pinned dependencies (which is the default) ([#162](https://github.com/jorisroovers/gitlint/issues/162)) +- Under-the-hood: dependencies updated + +# v0.16.0 (2021-10-08) + +Contributors: +Special thanks to all contributors for this release, in particular [sigmavirus24](https://github.com/sigmavirus24), [l0b0](https://github.com/l0b0) and [rafaelbubach](https://github.com/rafaelbubach). + +## General +- Python 3.10 support +- Heads-up: [Python 3.6 will become EOL at the end of 2021](https://endoflife.date/python). It's likely that future gitlint releases will stop supporting Python 3.6 as a result. We will continue to support Python 3.6 as long as it's easily doable, which in practice usually means as long as our dependencies support it. + +## Features +- `--commit ` flag to more easily lint a single commit message ([#141](https://github.com/jorisroovers/gitlint/issues/141)) +- `--fail-without-commits` flag will force gitlint to fail ([exit code 253](https://jorisroovers.com/gitlint/#exit-codes)) when the target commit range is empty (typically when using `--commits`) ([#193](https://github.com/jorisroovers/gitlint/issues/193)) + +## Rules +- **New Rule**: [ignore-by-author-name](http://jorisroovers.github.io/gitlint/rules/#i4-ignore-by-author-name) allows users to skip linting commit messages made by specific authors + +## Bugfixes + - [contrib-title-conventional-commits (CT1)](https://jorisroovers.com/gitlint/contrib_rules/#ct1-contrib-title-conventional-commits) now properly enforces the commit type ([#185](https://github.com/jorisroovers/gitlint/issues/185)) + - [contrib-title-conventional-commits (CT1)](https://jorisroovers.com/gitlint/contrib_rules/#ct1-contrib-title-conventional-commits) now supports the BREAKING CHANGE symbol "!" ([#186](https://github.com/jorisroovers/gitlint/issues/186)) + +## Development +- Dependencies updated +- Test and github action improvements + +# v0.15.1 (2021-04-16) + +Contributors: +Special thanks to all contributors for this release, in particular [PW999](https://github.com/PW999), [gsemet](https://github.com/gsemet) and [Lorac](https://github.com/Lorac). + +## Bugfixes + - Git commit message body with only new lines is not longer considered empty by `body-is-missing` ([#176](https://github.com/jorisroovers/gitlint/issues/176)) + - Added compatibility with `git commit -s` for `contrib-requires-signed-off-by` rule ([#178](https://github.com/jorisroovers/gitlint/pull/178)) +- Minor tweak to gitlint commit-hook output ([#173](https://github.com/jorisroovers/gitlint/pull/173)) +- All dependencies have been upgraded to the latest available versions (`Click==7.1.2`, `arrow==1.0.3`, `sh==1.14.1`). +- Minor doc fixes + +# v0.15.0 (2020-11-27) + +Contributors: +Special thanks to [BrunIF](https://github.com/BrunIF), [lukech](https://github.com/lukech), [Cielquan](https://github.com/Cielquan), [harens](https://github.com/harens) and [sigmavirus24](https://github.com/sigmavirus24). + +## General + +- **This release drops support for Python 2.7 and Python 3.5 ([both are EOL](https://endoflife.date/python)). Other than a few minor fixes, there are no functional differences from the 0.14.0 release.** +- **Mac users**: Gitlint can now be installed using both homebrew (upgraded to latest) and macports. Special thanks to [@harens](https://github.com/harens) for maintaining these packages (best-effort). + +## Bugfixes +- Gitlint now properly handles exceptions when using its built-in commit-msg hook ([#166](https://github.com/jorisroovers/gitlint/issues/166)). + +## Development +- All dependencies have been upgraded to the latest available versions (`Click==7.1.2`, `arrow==0.17.0`, `sh==1.14.1`). +- Much under-the-hood refactoring as a result of dropping Python 2.7 + +# v0.14.0 (2020-10-24) + +Contributors: +Special thanks to all contributors for this release, in particular [mrshu](https://github.com/mrshu), [glasserc](https://github.com/glasserc), [strk](https://github.com/strk), [chgl](https://github.com/chgl), [melg8](https://github.com/melg8) and [sigmavirus24](https://github.com/sigmavirus24). + +## General +- **IMPORTANT: Gitlint 0.14.x will be the last gitlint release to support Python 2.7 and Python 3.5, as [both are EOL](https://endoflife.date/python) which makes it difficult to keep supporting them.** +- Python 3.9 support +- [Named Rules](http://jorisroovers.github.io/gitlint/#named-rules) allow users to have multiple instances of the same rule active at the same time. This is useful when you want to enforce the same rule multiple times but with different options ([#113](https://github.com/jorisroovers/gitlint/issues/113), [#66](https://github.com/jorisroovers/gitlint/issues/66)) +- [User-defined Configuration Rules](http://jorisroovers.github.io/gitlint/user_defined_rules/#configuration-rules) allow users to dynamically change gitlint's configuration and/or the commit *before* any other rules are applied. +- The `commit-msg` hook has been re-written in Python (it contained a lot of Bash before), fixing a number of platform specific issues. Existing users will need to reinstall their hooks (`gitlint uninstall-hook; gitlint install-hook`) to make use of this. +- Most general options can now be set through environment variables (e.g. set the `general.ignore` option via `GITLINT_IGNORE=T1,T2`). The list of available environment variables can be found in the [configuration documentation](http://jorisroovers.github.io/gitlint/configuration). +- Users can now use `self.log.debug("my message")` for debugging purposes in their user-defined rules. Debug messages will show up when running `gitlint --debug`. +- **Breaking**: User-defined rule id's can no longer start with 'I', as those are reserved for [built-in gitlint ignore rules](http://jorisroovers.github.io/gitlint/rules/#i1-ignore-by-title). +- New `RegexOption` rule [option type for use in user-defined rules](http://jorisroovers.github.io/gitlint/user_defined_rules/#options). By using the `RegexOption`, regular expressions are pre-validated at gitlint startup and compiled only once which is much more efficient when linting multiple commits. + +## Rules +- **New Rule**: [title-min-length](http://jorisroovers.github.io/gitlint/rules/#t8-title-min-length) enforces a minimum length on titles (default: 5 chars) ([#138](https://github.com/jorisroovers/gitlint/issues/138)) +- **New Rule**: [body-match-regex](http://jorisroovers.github.io/gitlint/rules/#b8-body-match-regex) allows users to enforce that the commit-msg body matches a given regex ([#130](https://github.com/jorisroovers/gitlint/issues/130)) +- **New Rule**: [ignore-body-lines](http://jorisroovers.github.io/gitlint/rules/#i3-ignore-body-lines) allows users to +[ignore parts of a commit](http://jorisroovers.github.io/gitlint/gitlint/#ignoring-commits) by matching a regex against +the lines in a commit message body ([#126](https://github.com/jorisroovers/gitlint/issues/126)) + +## Contrib Rules +- Added 'ci' and 'build' to conventional commit types ([#135](https://github.com/jorisroovers/gitlint/issues/135)) + +## Bugfixes +- Improved UTF-8 fallback on Windows (ongoing - [#96](https://github.com/jorisroovers/gitlint/issues/96)) +- Windows users can now use the 'edit' function of the `commit-msg` hook ([#94](https://github.com/jorisroovers/gitlint/issues/94)) +- Doc update: Users should use `--ulimit nofile=1024` when invoking gitlint using Docker ([#129](https://github.com/jorisroovers/gitlint/issues/129)) +- The `commit-msg` hook was broken in Ubuntu's gitlint package due to a python/python3 mismatch ([#127](https://github.com/jorisroovers/gitlint/issues/127)) +- Better error message when no git username is set ([#149](https://github.com/jorisroovers/gitlint/issues/149)) +- Options can now actually be set to `None` (from code) to make them optional. +- Ignore rules no longer have `"None"` as default regex, but an empty regex - effectively disabling them by default (as intended). + +## Development +- Minor performance improvements (removed some unnecessary regex matching), +- Test improvements, +- Improved debug logging, +- CI runs on pull requests +- PR request template + +# v0.13.1 (2020-02-26) + +## Bugfixes +- Patch to enable `--staged` flag for pre-commit. +- Minor doc updates ([#109](https://github.com/jorisroovers/gitlint/issues/109)) + +# v0.13.0 (2020-02-25) + +## General +- Python 3.8 support +- Python 3.4 no longer supported. Python 3.4 has [reached EOL](https://www.python.org/dev/peps/pep-0429/#id4) and an increasing + of gitlint's dependencies have dropped support which makes it hard to maintain. +- Improved Windows support: better unicode handling. [Issues remain](https://github.com/jorisroovers/gitlint/issues?q=is%3Aissue+is%3Aopen+label%3Awindows) but the basic functionality works. +- **Behavior Change**: Revert Commits are now recognized and ignored by default ([#99](https://github.com/jorisroovers/gitlint/issues/99)) + +## Features +- `--staged` flag: gitlint can now detect meta-data (such as author details, changed files, etc) of staged/pre-commits. Useful when you use [gitlint's commit-msg hook](https://jorisroovers.github.io/gitlint/#using-gitlint-as-a-commit-msg-hook) or [precommit](https://jorisroovers.github.io/gitlint/#using-gitlint-through-pre-commit) ([#105](https://github.com/jorisroovers/gitlint/issues/105)) +- New branch properties on `GitCommit` and `GitContext`, useful when writing your own user-defined rules: `commit.branches` and `commit.context.current_branch` ([#108](https://github.com/jorisroovers/gitlint/issues/108)) + +## Bugfixes + - Gitlint no longer crashes when acting on empty repositories (this only occurred in specific circumstances). + - Changed files are now better detected in repos that only have a root commit +- Improved performance and memory (gitlint now caches git properties) +- Improved `--debug` output +- Improved documentation + +## Development +- Dependencies updated +- Unit and integration test improvements +- Migrated from TravisCI to Github Actions. + +# v0.12.0 (2019-07-15) + +Contributors: +Special thanks to all contributors for this release, in particular [@rogalksi](https://github.com/rogalski) and [@byrney](https://github.com/byrney). + +## General +- Python 3.3 no longer supported. Python 3.4 is likely to follow in a future release as it has [reached EOL](https://www.python.org/dev/peps/pep-0429/#id4) as well. +- PyPy 3.5 support + + +## Features +- [Contrib Rules](http://jorisroovers.github.io/gitlint/contrib_rules): community-contributed rules that are disabled + by default, but can be enabled through configuration. Contrib rules are meant to augment default gitlint behavior by + providing users with rules for common use-cases without forcing these rules on all gitlint users. + - **New Contrib Rule**: `contrib-title-conventional-commits` enforces the [Conventional Commits](https://www.conventionalcommits.org) spec. Details in our [documentation](http://jorisroovers.github.io/gitlint/contrib_rules/#ct1-contrib-title-conventional-commits). + - **New Contrib Rule**: `cc1-contrib-requires-signed-off-by` ensures that all commit messages contain a `Sign-Off-By` line. Details in our [documentation](http://jorisroovers.github.io/gitlint/contrib_rules/#cc1-contrib-requires-signed-off-by). + - If you're interested in adding new Contrib rules to gitlint, please start by reading the + [Contributing](http://jorisroovers.github.io/gitlint/contributing/) page. Thanks for considering! +- *Experimental (!)* Windows support: Basic functionality is working, but there are still caveats. For more details, please refer to [#20](https://github.com/jorisroovers/gitlint/issues/20) and the [open issues related to Windows](https://github.com/jorisroovers/gitlint/issues?q=is%3Aissue+is%3Aopen+label%3Awindows). +- Support for `--ignore-stdin` command-line flag to ignore any text send via stdin. ([#56](https://github.com/jorisroovers/gitlint/issues/56), [#89](https://github.com/jorisroovers/gitlint/issues/89)) + +## Bugfixes + - [#68: Can't use install-hooks in with git worktree](https://github.com/jorisroovers/gitlint/issues/68) + - [#59: gitlint failed with configured commentchar](https://github.com/jorisroovers/gitlint/issues/59) + +## Development +- Dependencies updated +- Experimental Dockerfile +- Github issue template. + +# v0.11.0 (2019-03-13) + +## General +- Python 3.7 support +- Python 2.6 no longer supported + +## Development +- Various dependency updates and under the hood fixes (see [#76](https://github.com/jorisroovers/gitlint/pull/76) for details). + +Special thanks to @pbregener for his contributions related to python 3.7 support and test fixes. + +# v0.10.0 (2018-04-15) +The 0.10.0 release adds the ability to ignore commits based on their contents, +support for [pre-commit](https://pre-commit.com/), and important fix for running gitlint in CI environments +(such as Jenkins, Gitlab, etc). + +Special thanks to [asottile](https://github.com/asottile), [bdrung](https://github.com/bdrung), [pbregener](https://github.com/pbregener), [torwald-sergesson](https://github.com/torwald-sergesson), [RykHawthorn](https://github.com/RykHawthorn), [SteffenKockel](https://github.com/SteffenKockel) and [tommyip](https://github.com/tommyip) for their contributions. + +## General +- **Since it's becoming increasingly hard to support Python 2.6 and 3.3, we'd like to encourage our users to upgrade their + python version to 2.7 or 3.3+. Future versions of gitlint are likely to drop support for Python 2.6 and 3.3.** + +## Features +- Gitlint now supports [pre-commit.com](https://pre-commit.com). +[Details in our documentation](http://jorisroovers.github.io/gitlint/#using-gitlint-through-pre-commit) +([#62](https://github.com/jorisroovers/gitlint/issues/62)). +- Gitlint now has a `--msg-filename` commandline flag that allows you to specify the commit message to lint via + a file ([#39](https://github.com/jorisroovers/gitlint/issues/39)). +- Gitlint will now be silent by default when a specified commit range is empty ([#46](https://github.com/jorisroovers/gitlint/issues/46)). +- Gitlint can now be installed on MacOS by brew via the [homebrew-devops](https://github.com/rockyluke/homebrew-devops) tap. To get the latest version of gitlint, always use pip for installation. +- If all goes well, +[gitlint will also be available as a package in the Ubuntu 18.04 repositories](https://launchpad.net/ubuntu/+source/gitlint). + +## Rules +- **New Rule**: `ignore-by-title` allows users to +[ignore certain commits](http://jorisroovers.github.io/gitlint/#ignoring-commits) by matching a regex against +a commit message title. ([#54](https://github.com/jorisroovers/gitlint/issues/54), [#57](https://github.com/jorisroovers/gitlint/issues/57)). +- **New Rule**: `ignore-by-body` allows users to +[ignore certain commits](http://jorisroovers.github.io/gitlint/#ignoring-commits) by matching a regex against +a line in a commit message body. + +## Bugfixes +- We fixed a nasty and recurring issue with running gitlint in CI. Hopefully that's the end of it :-) ([#40](https://github.com/jorisroovers/gitlint/issues/40)). +- Fix for custom git comment characters ([#48](https://github.com/jorisroovers/gitlint/issues/48)). + +# v0.9.0 (2017-12-03) +The 0.9.0 release adds a new default `author-valid-email` rule, important bugfixes and special case handling. +Special thanks to [joshholl](https://github.com/joshholl), [ron8mcr](https://github.com/ron8mcr), +[omarkohl](https://github.com/omarkohl), [domo141](https://github.com/domo141), [nud](https://github.com/nud) +and [AlexMooney](https://github.com/AlexMooney) for their contributions. + +## General +- **Breaking change**: The `--commits` commandline flag now strictly follows the refspec format as interpreted + by the [`git rev-list `](https://git-scm.com/docs/git-rev-list) command. This means + that linting a single commit using `gitlint --commits ` won't work anymore. Instead, for single commits, + users now need to specificy `gitlint --commits ^...`. On the upside, this change also means + that gitlint will now understand all refspec formatters, including `gitlint --commits HEAD` to lint all commits + in the repository. This fixes [#23](https://github.com/jorisroovers/gitlint/issues/23). +- **Breaking change**: Gitlint now always falls back on trying to read a git message from a local git repository, only + reading a commit message from STDIN if one is passed. Before, gitlint only read from the local git repository when + a TTY was present. This is likely the expected and desired behavior for anyone running gitlint in a CI environment. + This fixes [#40](https://github.com/jorisroovers/gitlint/issues/40) and + [#42](https://github.com/jorisroovers/gitlint/issues/42). +- **Behavior Change**: Gitlint will now by default + [ignore squash and fixup commits](http://jorisroovers.github.io/gitlint/#merge-fixup-and-squash-commits) + (fix for [#33: fixup messages should not trigger a gitlint violation](https://github.com/jorisroovers/gitlint/issues/33)) + +## Features +- Support for custom comment characters ([#34](https://github.com/jorisroovers/gitlint/issues/34)) +- Support for [`git commit --cleanup=scissors`](https://git-scm.com/docs/git-commit#git-commit---cleanupltmodegt) + ([#34](https://github.com/jorisroovers/gitlint/issues/34)) + +## Rules +- New Rule: `author-valid-email` enforces a valid author email address. Details can be found in the + [Rules section of the documentation](http://jorisroovers.github.io/gitlint/rules/#m1-author-valid-email). + +## Bugfixes +- [#37: Prevent Commas in text fields from breaking git log printing](https://github.com/jorisroovers/gitlint/issues/37) + +## Development +- Debug output improvements + +# v0.8.2 (2017-04-25) + +The 0.8.2 release brings minor improvements, bugfixes and some under-the-hood changes. Special thanks to +[tommyip](https://github.com/tommyip) for his contributions. + +## Features +- `--extra-path` now also accepts a file path (in the past only directory paths where accepted). +Thanks to [tommyip](https://github.com/tommyip) for implementing this! +- gitlint will now show more information when using the `--debug` flag. This is initial work and will continue to +be improved upon in later releases. + +## Bugfixes + - [#24: --commits doesn't take commit specific config into account](https://github.com/jorisroovers/gitlint/issues/24) + - [#27: --commits returns the wrong exit code](https://github.com/jorisroovers/gitlint/issues/27) +## Development +- Better unit and integration test coverage for `--commits` + +# v0.8.1 (2017-03-16) + +The 0.8.1 release brings minor tweaks and some experimental features. Special thanks to +[tommyip](https://github.com/tommyip) for his contributions. + +## General +- Experimental: Python 3.6 support +- Improved Windows error messaging: gitlint will now show a more descriptive error message when ran on windows. + See [#20](https://github.com/jorisroovers/gitlint/issues/20) for details on the lack of Windows support. + +## Features +- Experimental: Linting a range of commits. + [Documentation](http://jorisroovers.github.io/gitlint/#linting-a-range-of-commits). + Known Caveats: [#23](https://github.com/jorisroovers/gitlint/issues/23), + [#24](https://github.com/jorisroovers/gitlint/issues/24). + Closes [#14](https://github.com/jorisroovers/gitlint/issues/14). Thanks to [tommyip](https://github.com/tommyip) + for implementing this! + +# v0.8.0 (2016-12-30) + +The 0.8.0 release is a significant release that has been in the works for a long time. Special thanks to +[Claymore](https://github.com/Claymore), [gernd](https://github.com/gernd) and +[ZhangYaxu](https://github.com/ZhangYaxu) for submitting bug reports and pull requests. + +## General +- Full unicode support: you can now lint messages in any language! This fixes + [#16](https://github.com/jorisroovers/gitlint/issues/16) and [#18](https://github.com/jorisroovers/gitlint/pull/18). +- Pypy2 support! +- Various documentation improvements + +## Features +- User-defined rules: you can now + [define your own custom rules](http://jorisroovers.github.io/gitlint/user_defined_rules/) + if you want to extend gitlint's functionality. +- Debug output improvements: Gitlint will now print your active configuration when using `--debug` +- The `general.target` option can now also be set via `-c` flags or a `.gitlint` file + +## Bugfixes +- Various important fixes related to configuration precedence +- [#17: Body MinLength is not working properly](https://github.com/jorisroovers/gitlint/issues/17). + **Behavior Change**: Gitlint now always applies this rule, even if the body has just a single line of content. + Also, gitlint now counts the body-length for the entire body, not just the length of the first line. + +## Development +- Pylint compliance for all supported python versions +- Updated dependencies to latest versions +- Various `run_tests.sh` improvements for developer convenience + +# v0.7.1 (2016-06-18) +## Bugfixes + +- **Behavior Change**: gitlint no longer prints the file path by default when using a `.gitlint` file. The path +will still be printed when using the new `--debug` flag. Special thanks to [Slipcon](https://github.com/slipcon) +for submitting this. +- Gitlint now prints a correct violation message for the `title-match-regex` rule. Special thanks to +[Slipcon](https://github.com/slipcon) for submitting this. +- Gitlint is now better at parsing commit messages cross-platform by taking platform specific line endings into account +- Minor documentation improvements + +# v0.7.0 (2016-04-20) +This release contains mostly bugfix and internal code improvements. Special thanks to +[William Turell](https://github.com/wturrell) and [Joe Grund](https://github.com/jgrund) for bug reports and pull +requests. + +## General +- Python 2.6 support +- **Behavior change**: merge commits are now ignored by default. The rationale is that the original commits + should already be linted and that many merge commits don't pass gitlint checks by default + (e.g. exceeding title length or empty body is very common). This behavior can be overwritten by setting the + general option `ignore-merge-commit=false`. + +## Features +- commit-msg hooks improvements: The new commit-msg hook now allows you to edit your message if it contains violations, + prints the commit message on aborting and is more compatible with GUI-based git clients such as SourceTree. + *You will need to uninstall and reinstall the commit-msg hook for these latest features*. + +## Bugfixes +- [#7: Hook compatibility with SourceTree](https://github.com/jorisroovers/gitlint/issues/7) +- [#8: Illegal option -e](https://github.com/jorisroovers/gitlint/issues/8) +- [#9: print full commit msg to stdout if aborted](https://github.com/jorisroovers/gitlint/issues/9) +- [#11 merge commit titles exceeding the max title length by default](https://github.com/jorisroovers/gitlint/issues/11) +- Better error handling of invalid general options + +## Development +- internal refactoring to extract more info from git. This will allow for more complex rules in the future. +- initial set of integration tests. Test gitlint end-to-end after it is installed. +- pylint compliance for python 2.7 + +# v0.6.1 (2015-11-22) + +## Bugfixes + +- `install-hook` and `generate-config` commands not working when gitlint is installed from pypi. + +# v0.6.0 (2015-11-22) + +## General +- Python 3 (3.3+) support! +- All documentation is now hosted on [http://jorisroovers.github.io/gitlint/]() +- **Breaking change**: exit code behavior has changed. More details in the + [Exit codes section of the documentation](http://jorisroovers.github.io/gitlint/#exit-codes). +- **Breaking change**: `--install-hook` and `--uninstall-hook` have been renamed to `install-hook` and + `uninstall-hook` respectively to better express that they are commands instead of options. + +## Features +- New `generate-config` command generates a sample gitlint config file +- New `--target` flag allows users to lint different directories than the current working directory +- Better error handling when gitlint is executed in a directory that is not a git repository or + when git is not installed. +- The git commit message hook now uses pretty colored output + +## Bugfixes +- `--config` option no longer accepts directories as value + +## Development +- Unit tests are now ran using py.test + +# v0.5.0 (2015-10-04) + +## Features + +- Uninstall previously installed gitlint git commit hooks using: `gitlint --uninstall-hook` +- Ignore rules on a per commit basis by adding e.g.: `gitlint-ignore: T1, body-hard-tab` to your git commit message. + Use `gitlint-ignore: all` to disable gitlint all together for a specific commit. +- `body-is-missing` will now automatically be disabled for merge commits (use the `ignore-merge-commit: false` + option to disable this behavior) +- Violations are now sorted by line number first and then by rule id (previously the order of violations on the + same line was arbitrary). + +## Rules +- New Rule: `title-match-regex`. Details can be found in the + [Rules section of the documentation](http://jorisroovers.github.io/gitlint/rules/). + +# v0.4.1 (2015-09-19) + +## Bugfixes +- Added missing comma to setup.py which prevented pypi upload + +# v0.4.0 (2015-09-19) + +## General +- gitlint is now also released as a [python wheel](http://pythonwheels.com/) on pypi. + +## Features +- The git `commit-msg` hook now allows you to keep or discard the commit when it fails gitlint validation + +## Rules + +- New rules: `body-is-missing`, `body-min-length`, `title-leading-whitespace`, + `body-changed-file-mention`. Details can be found in the + [Rules section of the documentation](http://jorisroovers.github.io/gitlint/rules/). + +## Development +- Internal: rule classes now have access to a gitcontext containing body the commit message and the files changed in the + last commit. + +# v0.3.0 (2015-09-11) +## Features +- gitlint violations are now printed to the stderr instead of stdout +- gitlint now ignores commented out lines (i.e. starting with #) in your commit messages +- Experimental: git commit-msg hook support + +## Rules +- `title-must-not-contain-word` now has a `words` option that can be used to specify which words should not + occur in the title + +## Bugfixes +- Various minor bugfixes + +## Development +- Under-the-hood: better test coverage :-) + +# v0.2.0 (2015-09-10) + +## Features +- Rules can now have their behavior configured through options. + For example, the `title-max-length` rule now has a `line-length` option. + +## Development + - The codebase now has a basic level of unit test coverage, increasing overall quality assurance + +# v0.1.1 (2015-09-08) + +## Bugfixes +- Added missing `sh` dependency + +# v0.1.0 (2015-09-08) + +## General +- Initial gitlint release +- Initial set of rules: title-max-length, title-trailing-whitespace, title-trailing-punctuation , title-hard-tab, + title-must-not-contain-word, body-max-line-length, body-trailing-whitespace, body-hard-tab +- General gitlint configuration through a `gitlint` file +- Silent and verbose mode +- Vagrantfile for easy development +- gitlint is available on [pypi](https://pypi.python.org/pypi/gitlint) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..892ff53 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,6 @@ +# Contributing + +Thanks for your interest in contributing to gitlint! + +Instructions on how to get started can be found on [http://jorisroovers.github.io/gitlint/contributing](http://jorisroovers.github.io/gitlint/contributing/). + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..641296e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +# To lint your current working directory: +# docker run --ulimit nofile=1024 -v $(pwd):/repo jorisroovers/gitlint + +# With arguments: +# docker --ulimit nofile=1024 run -v $(pwd):/repo jorisroovers/gitlint --debug --ignore T1 + +# NOTE: --ulimit is required to work around a limitation in Docker +# Details: https://github.com/jorisroovers/gitlint/issues/129 + +FROM python:3.11.2-alpine +ARG GITLINT_VERSION + +RUN apk add git +RUN pip install gitlint==$GITLINT_VERSION + +RUN git config --global --add safe.directory /repo +ENTRYPOINT ["gitlint", "--target", "/repo"] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..122bd28 --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 Joris Roovers + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..05787be --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +# gitlint: [jorisroovers.github.io/gitlint](http://jorisroovers.github.io/gitlint/) # + +[![Tests](https://github.com/jorisroovers/gitlint/workflows/Tests%20and%20Checks/badge.svg)](https://github.com/jorisroovers/gitlint/actions?query=workflow%3A%22Tests+and+Checks%22) +[![Coverage Status](https://coveralls.io/repos/github/jorisroovers/gitlint/badge.svg?branch=fix-coveralls)](https://coveralls.io/github/jorisroovers/gitlint?branch=fix-coveralls) +[![PyPi Package](https://img.shields.io/pypi/v/gitlint.png)](https://pypi.python.org/pypi/gitlint) +![Supported Python Versions](https://img.shields.io/pypi/pyversions/gitlint.svg) + +Git commit message linter written in python, checks your commit messages for style. + +**See [jorisroovers.github.io/gitlint](http://jorisroovers.github.io/gitlint/) for full documentation.** + + + + + +## Contributing ## +All contributions are welcome and very much appreciated! + +**I'm [looking for contributors](https://github.com/jorisroovers/gitlint/issues/134) that are interested in taking a more active co-maintainer role as it's becoming increasingly difficult for me to find time to maintain gitlint. Please leave a comment in [#134](https://github.com/jorisroovers/gitlint/issues/134) if you're interested!** + +See [jorisroovers.github.io/gitlint/contributing](http://jorisroovers.github.io/gitlint/contributing) for details on +how to get started - it's easy! + +We maintain a [loose project plan on Github Projects](https://github.com/users/jorisroovers/projects/1/views/1). diff --git a/docs/configuration.md b/docs/configuration.md new file mode 100644 index 0000000..af49d7c --- /dev/null +++ b/docs/configuration.md @@ -0,0 +1,628 @@ +# Configuration +Gitlint can be configured through different means. + +## The .gitlint file +You can modify gitlint's behavior by adding a `.gitlint` file to your git repository. + +Generate a default `.gitlint` config file by running: +```sh +gitlint generate-config +``` +You can also use a different config file like so: + +```sh +gitlint --config myconfigfile.ini +``` + +The block below shows a sample `.gitlint` file. Details about rule config options can be found on the +[Rules](rules.md) page, details about the `[general]` section can be found in the +[General Configuration](configuration.md#general-configuration) section of this page. + +```ini +# Edit this file as you like. +# +# All these sections are optional. Each section with the exception of [general] represents +# one rule and each key in it is an option for that specific rule. +# +# Rules and sections can be referenced by their full name or by id. For example +# section "[body-max-line-length]" could also be written as "[B1]". Full section names are +# used in here for clarity. +# Rule reference documentation: http://jorisroovers.github.io/gitlint/rules/ +# +# Use 'gitlint generate-config' to generate a config file with all possible options +[general] +# Ignore certain rules (comma-separated list), you can reference them by their +# id or by their full name +ignore=title-trailing-punctuation, T3 + +# verbosity should be a value between 1 and 3, the commandline -v flags take +# precedence over this +verbosity = 2 + +# By default gitlint will ignore merge, revert, fixup, fixup=amend, and squash commits. +ignore-merge-commits=true +ignore-revert-commits=true +ignore-fixup-commits=true +ignore-fixup-amend-commits=true +ignore-squash-commits=true + +# Ignore any data sent to gitlint via stdin +ignore-stdin=true + +# Fetch additional meta-data from the local repository when manually passing a +# commit message to gitlint via stdin or --commit-msg. Disabled by default. +staged=true + +# Hard fail when the target commit range is empty. Note that gitlint will +# already fail by default on invalid commit ranges. This option is specifically +# to tell gitlint to fail on *valid but empty* commit ranges. +# Disabled by default. +fail-without-commits=true + +# Whether to use Python `search` instead of `match` semantics in rules that use +# regexes. Context: https://github.com/jorisroovers/gitlint/issues/254 +# Disabled by default, but will be enabled by default in the future. +regex-style-search=true + +# Enable debug mode (prints more output). Disabled by default. +debug=true + +# Enable community contributed rules +# See http://jorisroovers.github.io/gitlint/contrib_rules for details +contrib=contrib-title-conventional-commits,CC1 + +# Set the extra-path where gitlint will search for user defined rules +# See http://jorisroovers.github.io/gitlint/user_defined_rules for details +extra-path=examples/ + +# This is an example of how to configure the "title-max-length" rule and +# set the line-length it enforces to 80 +[title-max-length] +line-length=80 + +# Conversely, you can also enforce minimal length of a title with the +# "title-min-length" rule: +[title-min-length] +min-length=5 + +[title-must-not-contain-word] +# Comma-separated list of words that should not occur in the title. Matching is case +# insensitive. It's fine if the keyword occurs as part of a larger word (so "WIPING" +# will not cause a violation, but "WIP: my title" will. +words=wip + +[title-match-regex] +# python like regex (https://docs.python.org/3/library/re.html) that the +# commit-msg title must be matched to. +# Note that the regex can contradict with other rules if not used correctly +# (e.g. title-must-not-contain-word). +regex=^US[0-9]* + +[body-max-line-length] +line-length=120 + +[body-min-length] +min-length=5 + +[body-is-missing] +# Whether to ignore this rule on merge commits (which typically only have a title) +# default = True +ignore-merge-commits=false + +[body-changed-file-mention] +# List of files that need to be explicitly mentioned in the body when they are changed +# This is useful for when developers often erroneously edit certain files or git submodules. +# By specifying this rule, developers can only change the file when they explicitly +# reference it in the commit message. +files=gitlint-core/gitlint/rules.py,README.md + +[body-match-regex] +# python-style regex that the commit-msg body must match. +# E.g. body must end in My-Commit-Tag: foo +regex=My-Commit-Tag: foo$ + +[author-valid-email] +# python like regex (https://docs.python.org/3/library/re.html) that the +# commit author email address should be matched to +# E.g.: For example, use the following regex if you only want to allow email +# addresses from foo.com +regex=[^@]+@foo.com + +[ignore-by-title] +# Ignore certain rules for commits of which the title matches a regex +# E.g. Match commit titles that start with "Release" +regex=^Release(.*) + +# Ignore certain rules, you can reference them by their id or by their full name +# Use 'all' to ignore all rules +ignore=T1,body-min-length + +[ignore-by-body] +# Ignore certain rules for commits of which the body has a line that matches a regex +# E.g. Match bodies that have a line that that contain "release" +regex=(.*)release(.*) +# +# Ignore certain rules, you can reference them by their id or by their full name +# Use 'all' to ignore all rules +ignore=T1,body-min-length + +[ignore-body-lines] +# Ignore certain lines in a commit body that match a regex. +# E.g. Ignore all lines that start with 'Co-Authored-By' +regex=^Co-Authored-By + +[ignore-by-author-name] +# Ignore certain rules for commits of which the author name matches a regex +# E.g. Match commits made by dependabot +regex=(.*)dependabot(.*) + +# Ignore certain rules, you can reference them by their id or by their full name +# Use 'all' to ignore all rules +ignore=T1,body-min-length + +# This is a contrib rule - a community contributed rule. These are disabled by default. +# You need to explicitly enable them one-by-one by adding them to the "contrib" option +# under [general] section above. +[contrib-title-conventional-commits] +# Specify allowed commit types. For details see: https://www.conventionalcommits.org/ +types = bugfix,user-story,epic +``` + +## Commandline config + +You can also use one or more `-c` flags like so: + +``` +$ gitlint -c general.verbosity=2 -c title-max-length.line-length=80 -c B1.line-length=100 +``` +The generic config flag format is `-c .