From 85812cd25d9e2f015bb71b26d51458b3718bf6c7 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 3 Nov 2020 07:07:48 +0100 Subject: Merging upstream version 0.14.0. Signed-off-by: Daniel Baumann --- .github/PULL_REQUEST_TEMPLATE.md | 13 + .github/workflows/checks.yml | 44 ++- .gitignore | 4 +- CHANGELOG.md | 120 ++++++--- Dockerfile | 9 +- README.md | 2 +- Vagrantfile | 5 +- doc-requirements.txt | 2 +- docs/configuration.md | 296 +++++++++++---------- docs/contrib_rules.md | 12 +- docs/contributing.md | 55 ++-- docs/extra.js | 5 + docs/index.md | 176 ++++++++---- docs/rules.md | 244 ++++++++++++++--- docs/user_defined_rules.md | 264 ++++++++++++------ examples/commit-message-11 | 7 + examples/my_commit_rules.py | 10 + examples/my_configuration_rules.py | 72 +++++ examples/my_line_rules.py | 9 +- gitlint/__init__.py | 2 +- gitlint/cli.py | 144 ++++++++-- gitlint/config.py | 65 ++++- gitlint/contrib/rules/conventional_commit.py | 2 +- gitlint/display.py | 5 +- gitlint/files/commit-msg | 78 ++---- gitlint/files/gitlint | 25 +- gitlint/git.py | 34 ++- gitlint/options.py | 37 +++ gitlint/rule_finder.py | 41 +-- gitlint/rules.py | 131 +++++++-- gitlint/shell.py | 18 +- gitlint/tests/base.py | 41 ++- gitlint/tests/cli/test_cli.py | 78 +++--- gitlint/tests/cli/test_cli_hooks.py | 172 ++++++++++++ gitlint/tests/config/test_config.py | 62 +++-- gitlint/tests/config/test_config_builder.py | 81 +++++- gitlint/tests/config/test_config_precedence.py | 26 +- gitlint/tests/contrib/rules/__init__.py | 0 .../contrib/rules/test_conventional_commit.py | 47 ++++ gitlint/tests/contrib/rules/test_signedoff_by.py | 32 +++ gitlint/tests/contrib/test_contrib_rules.py | 2 +- gitlint/tests/contrib/test_conventional_commit.py | 47 ---- gitlint/tests/contrib/test_signedoff_by.py | 32 --- gitlint/tests/expected/cli/test_cli/test_contrib_1 | 3 + gitlint/tests/expected/cli/test_cli/test_debug_1 | 120 +++++++++ .../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 | 79 ++++++ .../cli/test_cli/test_lint_multiple_commits_1 | 8 + .../test_cli/test_lint_multiple_commits_config_1 | 6 + .../cli/test_cli/test_lint_staged_msg_filename_1 | 2 + .../cli/test_cli/test_lint_staged_msg_filename_2 | 82 ++++++ .../expected/cli/test_cli/test_lint_staged_stdin_1 | 3 + .../expected/cli/test_cli/test_lint_staged_stdin_2 | 84 ++++++ .../tests/expected/cli/test_cli/test_named_rules_1 | 4 + .../tests/expected/cli/test_cli/test_named_rules_2 | 82 ++++++ .../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 + gitlint/tests/expected/test_cli/test_contrib_1 | 3 - gitlint/tests/expected/test_cli/test_debug_1 | 102 ------- .../tests/expected/test_cli/test_input_stream_1 | 3 - .../expected/test_cli/test_input_stream_debug_1 | 3 - .../expected/test_cli/test_input_stream_debug_2 | 71 ----- .../expected/test_cli/test_lint_multiple_commits_1 | 8 - .../test_cli/test_lint_multiple_commits_config_1 | 6 - .../test_cli/test_lint_staged_msg_filename_1 | 2 - .../test_cli/test_lint_staged_msg_filename_2 | 70 ----- .../expected/test_cli/test_lint_staged_stdin_1 | 3 - .../expected/test_cli/test_lint_staged_stdin_2 | 72 ----- gitlint/tests/git/test_git.py | 10 +- gitlint/tests/git/test_git_commit.py | 40 ++- gitlint/tests/rules/test_body_rules.py | 46 ++++ gitlint/tests/rules/test_configuration_rules.py | 38 ++- gitlint/tests/rules/test_meta_rules.py | 9 + gitlint/tests/rules/test_rules.py | 5 + gitlint/tests/rules/test_title_rules.py | 34 ++- gitlint/tests/rules/test_user_rules.py | 137 ++++++---- gitlint/tests/samples/commit_message/no-violations | 6 + gitlint/tests/samples/config/named-rules | 8 + gitlint/tests/test_hooks.py | 14 +- gitlint/tests/test_lint.py | 94 ++++++- gitlint/tests/test_options.py | 122 ++++++--- gitlint/tests/test_utils.py | 20 +- gitlint/utils.py | 33 ++- mkdocs.yml | 11 +- qa/base.py | 19 +- .../test_commits/test_lint_staged_msg_filename_1 | 15 +- qa/expected/test_commits/test_lint_staged_stdin_1 | 15 +- qa/expected/test_config/test_config_from_env_1 | 93 +++++++ qa/expected/test_config/test_config_from_env_2 | 83 ++++++ .../test_config/test_config_from_file_debug_1 | 15 +- qa/expected/test_contrib/test_contrib_rules_1 | 2 +- qa/expected/test_named_rules/test_named_rule_1 | 5 + .../test_named_rules/test_named_user_rule_1 | 9 + .../test_user_defined_rules_examples_2 | 4 + .../test_user_defined_rules_extra_1 | 6 +- qa/samples/config/contrib-enabled | 0 qa/samples/config/named-rules | 8 + qa/samples/config/named-user-rules | 15 ++ qa/samples/user_rules/extra/extra_rules.py | 52 +++- qa/shell.py | 7 +- qa/test_config.py | 43 ++- qa/test_gitlint.py | 22 ++ qa/test_hooks.py | 12 + qa/test_named_rules.py | 23 ++ qa/test_user_defined.py | 17 +- qa/utils.py | 18 +- run_tests.sh | 37 ++- setup.py | 17 +- tools/windows/create-test-repo.bat | 20 +- 123 files changed, 3378 insertions(+), 1244 deletions(-) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 docs/extra.js create mode 100644 examples/commit-message-11 create mode 100644 examples/my_configuration_rules.py create mode 100644 gitlint/tests/contrib/rules/__init__.py create mode 100644 gitlint/tests/contrib/rules/test_conventional_commit.py create mode 100644 gitlint/tests/contrib/rules/test_signedoff_by.py delete mode 100644 gitlint/tests/contrib/test_conventional_commit.py delete mode 100644 gitlint/tests/contrib/test_signedoff_by.py create mode 100644 gitlint/tests/expected/cli/test_cli/test_contrib_1 create mode 100644 gitlint/tests/expected/cli/test_cli/test_debug_1 create mode 100644 gitlint/tests/expected/cli/test_cli/test_input_stream_1 create mode 100644 gitlint/tests/expected/cli/test_cli/test_input_stream_debug_1 create mode 100644 gitlint/tests/expected/cli/test_cli/test_input_stream_debug_2 create mode 100644 gitlint/tests/expected/cli/test_cli/test_lint_multiple_commits_1 create mode 100644 gitlint/tests/expected/cli/test_cli/test_lint_multiple_commits_config_1 create mode 100644 gitlint/tests/expected/cli/test_cli/test_lint_staged_msg_filename_1 create mode 100644 gitlint/tests/expected/cli/test_cli/test_lint_staged_msg_filename_2 create mode 100644 gitlint/tests/expected/cli/test_cli/test_lint_staged_stdin_1 create mode 100644 gitlint/tests/expected/cli/test_cli/test_lint_staged_stdin_2 create mode 100644 gitlint/tests/expected/cli/test_cli/test_named_rules_1 create mode 100644 gitlint/tests/expected/cli/test_cli/test_named_rules_2 create mode 100644 gitlint/tests/expected/cli/test_cli_hooks/test_hook_config_1_stderr create mode 100644 gitlint/tests/expected/cli/test_cli_hooks/test_hook_config_1_stdout create mode 100644 gitlint/tests/expected/cli/test_cli_hooks/test_hook_edit_1_stderr create mode 100644 gitlint/tests/expected/cli/test_cli_hooks/test_hook_edit_1_stdout create mode 100644 gitlint/tests/expected/cli/test_cli_hooks/test_hook_local_commit_1_stderr create mode 100644 gitlint/tests/expected/cli/test_cli_hooks/test_hook_local_commit_1_stdout create mode 100644 gitlint/tests/expected/cli/test_cli_hooks/test_hook_no_1_stderr create mode 100644 gitlint/tests/expected/cli/test_cli_hooks/test_hook_no_1_stdout create mode 100644 gitlint/tests/expected/cli/test_cli_hooks/test_hook_no_tty_1_stderr create mode 100644 gitlint/tests/expected/cli/test_cli_hooks/test_hook_no_tty_1_stdout create mode 100644 gitlint/tests/expected/cli/test_cli_hooks/test_hook_stdin_no_violations_1_stdout create mode 100644 gitlint/tests/expected/cli/test_cli_hooks/test_hook_stdin_violations_1_stderr create mode 100644 gitlint/tests/expected/cli/test_cli_hooks/test_hook_stdin_violations_1_stdout create mode 100644 gitlint/tests/expected/cli/test_cli_hooks/test_hook_yes_1_stderr create mode 100644 gitlint/tests/expected/cli/test_cli_hooks/test_hook_yes_1_stdout delete mode 100644 gitlint/tests/expected/test_cli/test_contrib_1 delete mode 100644 gitlint/tests/expected/test_cli/test_debug_1 delete mode 100644 gitlint/tests/expected/test_cli/test_input_stream_1 delete mode 100644 gitlint/tests/expected/test_cli/test_input_stream_debug_1 delete mode 100644 gitlint/tests/expected/test_cli/test_input_stream_debug_2 delete mode 100644 gitlint/tests/expected/test_cli/test_lint_multiple_commits_1 delete mode 100644 gitlint/tests/expected/test_cli/test_lint_multiple_commits_config_1 delete mode 100644 gitlint/tests/expected/test_cli/test_lint_staged_msg_filename_1 delete mode 100644 gitlint/tests/expected/test_cli/test_lint_staged_msg_filename_2 delete mode 100644 gitlint/tests/expected/test_cli/test_lint_staged_stdin_1 delete mode 100644 gitlint/tests/expected/test_cli/test_lint_staged_stdin_2 create mode 100644 gitlint/tests/samples/commit_message/no-violations create mode 100644 gitlint/tests/samples/config/named-rules 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_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_user_defined/test_user_defined_rules_examples_2 delete mode 100644 qa/samples/config/contrib-enabled create mode 100644 qa/samples/config/named-rules create mode 100644 qa/samples/config/named-user-rules create mode 100644 qa/test_named_rules.py 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/workflows/checks.yml b/.github/workflows/checks.yml index 348fb47..710245c 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -1,19 +1,27 @@ name: Tests and Checks -on: [push] +on: [push, pull_request] jobs: checks: runs-on: "ubuntu-latest" strategy: matrix: - python-version: [2.7, 3.5, 3.6, 3.7, 3.8, pypy2, pypy3] + python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9, pypy2, pypy3] os: ["macos-latest", "ubuntu-latest"] steps: - uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.sha }} # Checkout pull request HEAD commit instead of merge commit + + # Because gitlint is a tool that uses git itself under the hood, we remove git tracking from the checked out + # code by temporarily renaming the .git directory. + # This is to ensure that the tests don't have a dependency on the version control of gitlint itself. + - name: Temporarily remove git version control from code + run: mv .git ._git - name: Setup python - uses: actions/setup-python@v1 + uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} @@ -57,24 +65,36 @@ jobs: # with: # github-token: ${{ secrets.GITHUB_TOKEN }} + # Re-add git version control so we can run gitlint on itself. + - name: Re-add git version control to code + run: mv ._git .git + - name: Gitlint check - run: ./run_tests.sh -g + run: ./run_tests.sh -g --debug windows-checks: runs-on: windows-latest strategy: matrix: - python-version: [2.7, 3.5] + python-version: [2.7, 3.6] steps: - uses: actions/checkout@v2 - + with: + ref: ${{ github.event.pull_request.head.sha }} # Checkout pull request HEAD commit instead of merge commit + + # Because gitlint is a tool that uses git itself under the hood, we remove git tracking from the checked out + # code by temporarily renaming the .git directory. + # This is to ensure that the tests don't have a dependency on the version control of gitlint itself. + - name: Temporarily remove git version control from code + run: Rename-Item .git ._git + - name: Setup python - uses: actions/setup-python@v1 + uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - name: "Upgrade pip on Python 3" - if: matrix.python-version == '3.5' + if: matrix.python-version == '3.6' run: python -m pip install --upgrade pip - name: Install requirements @@ -88,8 +108,8 @@ jobs: - name: Tests (sanity) run: tools\windows\run_tests.bat "gitlint\tests\cli\test_cli.py::CLITests::test_lint" - - name: Tests (ignore test_cli.py) - run: pytest --ignore gitlint\tests\cli\test_cli.py -rw -s gitlint + - name: Tests (ignore cli\*) + run: pytest --ignore gitlint\tests\cli -rw -s gitlint - name: Tests (test_cli.py only - continue-on-error:true) run: tools\windows\run_tests.bat "gitlint\tests\cli\test_cli.py" @@ -109,5 +129,9 @@ jobs: - name: PyLint run: pylint gitlint qa --rcfile=".pylintrc" -r n + # Re-add git version control so we can run gitlint on itself. + - name: Re-add git version control to code + run: Rename-Item ._git .git + - name: Gitlint check run: gitlint --debug diff --git a/.gitignore b/.gitignore index c350158..e81c924 100644 --- a/.gitignore +++ b/.gitignore @@ -63,6 +63,8 @@ virtualenv # Vagrant .vagrant - # mkdocs site/ + +# pyenv +.python-version \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a3991d..509ebc8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,37 @@ # Changelog # +## 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). + + +- **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 +- **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)) +- [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/130), [#66](https://github.com/jorisroovers/gitlint/issues/130)) +- [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. +- 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). +- Contrib Rules: + - Added 'ci' and 'build' to conventional commit types ([#135](https://github.com/jorisroovers/gitlint/issues/135)) +- Under-the-hood: 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) - Patch to enable `--staged` flag for pre-commit. @@ -8,8 +40,8 @@ ## v0.13.0 (2020-02-25) - **Behavior Change**: Revert Commits are now recognized and ignored by default ([#99](https://github.com/jorisroovers/gitlint/issues/99)) -- ```--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)) +- `--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)) - 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. @@ -30,14 +62,14 @@ Special thanks to all contributors for this release, in particular [@rogalksi](h - [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). + - **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). - 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 -- 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)) +- 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) @@ -63,16 +95,16 @@ python version to 2.7 or 3.3+. Future versions of gitlint are likely to drop sup Full Changelog: -- **New Rule**: ```ignore-by-title``` allows users to +- **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 +- **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. - 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 +- 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. @@ -83,18 +115,18 @@ a line in a commit message body. - 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. +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. -- New Rule: ```author-valid-email``` enforces a valid author email address. Details can be found in the +- 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). -- **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 +- **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 @@ -105,7 +137,7 @@ and [AlexMooney](https://github.com/AlexMooney) for their contributions. [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)) - 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) +- Support for [`git commit --cleanup=scissors`](https://git-scm.com/docs/git-commit#git-commit---cleanupltmodegt) ([#34](https://github.com/jorisroovers/gitlint/issues/34)) - Bugfix: [#37: Prevent Commas in text fields from breaking git log printing](https://github.com/jorisroovers/gitlint/issues/37) - Debug output improvements @@ -115,14 +147,14 @@ and [AlexMooney](https://github.com/AlexMooney) for their contributions. 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. -- ```--extra-path``` now also accepts a file path (in the past only directory paths where accepted). +- `--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 +- 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``` +- Development: better unit and integration test coverage for `--commits` ## v0.8.1 (2017-03-16) ## @@ -151,8 +183,8 @@ The 0.8.0 release is a significant release that has been in the works for a long [define your own custom rules](http://jorisroovers.github.io/gitlint/user_defined_rules/) if you want to extend gitlint's functionality. - Pypy2 support! -- 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 +- 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). @@ -162,15 +194,15 @@ The 0.8.0 release is a significant release that has been in the works for a long - Development: - Pylint compliance for all supported python versions - Updated dependencies to latest versions - - Various ```run_tests.sh``` improvements for developer convenience + - 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) +- **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 +- 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 @@ -187,7 +219,7 @@ requests. - **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```. + general option `ignore-merge-commit=false`. - Bugfixes and enhancements: - [#7: Hook compatibility with SourceTree](https://github.com/jorisroovers/gitlint/issues/7) - [#8: Illegal option -e](https://github.com/jorisroovers/gitlint/issues/8) @@ -200,32 +232,32 @@ requests. ## v0.6.1 (2015-11-22) ## -- Fix: ```install-hook``` and ```generate-config``` commands not working when gitlint is installed from pypi. +- Fix: `install-hook` and `generate-config` commands not working when gitlint is installed from pypi. ## v0.6.0 (2015-11-22) ## - Python 3 (3.3+) support! - All documentation is now hosted on [http://jorisroovers.github.io/gitlint/]() -- New ```generate-config``` command generates a sample gitlint config file -- New ```--target``` flag allows users to lint different directories than the current working directory +- New `generate-config` command generates a sample gitlint config file +- New `--target` flag allows users to lint different directories than the current working directory - **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. +- **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. - 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 -- Fix: ```--config``` option no longer accepts directories as value +- Fix: `--config` option no longer accepts directories as value - Development: unit tests are now ran using py.test ## v0.5.0 (2015-10-04) ## -- New Rule: ```title-match-regex```. Details can be found in the +- New Rule: `title-match-regex`. Details can be found in the [Rules section of the documentation](http://jorisroovers.github.io/gitlint/rules/). -- 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``` +- 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). @@ -236,16 +268,16 @@ requests. ## v0.4.0 (2015-09-19) ## -- New rules: ```body-is-missing```, ```body-min-length```, ```title-leading-whitespace```, - ```body-changed-file-mention```. Details can be found in the +- 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/). -- The git ```commit-msg``` hook now allows you to keep or discard the commit when it fails gitlint validation +- The git `commit-msg` hook now allows you to keep or discard the commit when it fails gitlint validation - gitlint is now also released as a [python wheel](http://pythonwheels.com/) on pypi. - 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) ## -- ```title-must-not-contain-word``` now has a ```words``` option that can be used to specify which words should not +- `title-must-not-contain-word` now has a `words` option that can be used to specify which words should not occur in the title - gitlint violations are now printed to the stderr instead of stdout - Various minor bugfixes @@ -255,17 +287,17 @@ requests. ## v0.2.0 (2015-09-10) ## - Rules can now have their behavior configured through options. - For example, the ```title-max-length``` rule now has a ```line-length``` option. + For example, the `title-max-length` rule now has a `line-length` option. - Under-the-hood: The codebase now has a basic level of unit test coverage, increasing overall quality assurance ## v0.1.1 (2015-09-08) ## -- Bugfix: added missing ```sh``` dependency +- Bugfix: added missing `sh` dependency ## v0.1.0 (2015-09-08) ## - 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 +- 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/Dockerfile b/Dockerfile index b66bb71..9f93206 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,15 @@ # User-facing Dockerfile. For development, see Dockerfile.dev and ./run_tests.sh -h # To lint your current working directory: -# docker run -v $(pwd):/repo jorisroovers/gitlint +# docker run --ulimit nofile=1024 -v $(pwd):/repo jorisroovers/gitlint # With arguments: -# docker run -v $(pwd):/repo jorisroovers/gitlint --debug --ignore T1 +# docker --ulimit nofile=1024 run -v $(pwd):/repo jorisroovers/gitlint --debug --ignore T1 -FROM python:3.8-alpine +# NOTE: --ulimit is required to work around a limitation in Docker +# Details: https://github.com/jorisroovers/gitlint/issues/129 + +FROM python:3.9-alpine ARG GITLINT_VERSION RUN apk add git diff --git a/README.md b/README.md index 81f2ac9..43da74c 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Git commit message linter written in python (for Linux and Mac, experimental on ## Contributing ## All contributions are welcome and very much appreciated! -**I'm looking for contributors 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 open a PR if you're interested - Thanks!** +**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 open a PR if you're interested - Thanks!** See [jorisroovers.github.io/gitlint/contributing](http://jorisroovers.github.io/gitlint/contributing) for details on how to get started - it's easy! diff --git a/Vagrantfile b/Vagrantfile index 2a26aab..7684c1a 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -7,9 +7,10 @@ INSTALL_DEPS=<.