From e2d38cd54491535f409372393baeed787c77388d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 13 Oct 2021 07:34:57 +0200 Subject: Merging upstream version 0.16.0. Signed-off-by: Daniel Baumann --- .coveragerc | 6 +- .github/dependabot.yml | 14 +++++ .github/workflows/checks.yml | 8 ++- CHANGELOG.md | 14 +++++ Dockerfile | 2 +- README.md | 6 +- doc-requirements.txt | 2 +- docs/configuration.md | 41 ++++++++++++- docs/contributing.md | 4 +- docs/images/readme-gitlint.png | Bin 0 -> 348007 bytes docs/index.md | 52 +++++++++-------- docs/rules.md | 31 ++++++++++ gitlint/__init__.py | 2 +- gitlint/cli.py | 62 ++++++++++++-------- gitlint/config.py | 14 +++++ gitlint/contrib/rules/conventional_commit.py | 17 +++--- gitlint/files/gitlint | 15 +++++ gitlint/git.py | 17 ++++-- gitlint/rules.py | 24 +++++++- gitlint/shell.py | 8 +-- gitlint/tests/base.py | 7 +++ gitlint/tests/cli/test_cli.py | 64 ++++++++++++++++++++- gitlint/tests/config/test_config.py | 7 ++- .../contrib/rules/test_conventional_commit.py | 28 +++++++++ gitlint/tests/expected/cli/test_cli/test_contrib_1 | 1 - gitlint/tests/expected/cli/test_cli/test_debug_1 | 4 ++ .../cli/test_cli/test_input_stream_debug_2 | 4 ++ .../tests/expected/cli/test_cli/test_lint_commit_1 | 2 + .../cli/test_cli/test_lint_staged_msg_filename_2 | 4 ++ .../expected/cli/test_cli/test_lint_staged_stdin_2 | 4 ++ .../tests/expected/cli/test_cli/test_named_rules_2 | 4 ++ gitlint/tests/git/test_git_commit.py | 64 +++++++++++++++++++-- gitlint/tests/rules/test_body_rules.py | 6 +- gitlint/tests/rules/test_configuration_rules.py | 33 +++++++++++ gitlint/tests/rules/test_title_rules.py | 2 +- gitlint/tests/rules/test_user_rules.py | 6 +- gitlint/tests/test_options.py | 2 +- qa/base.py | 40 ++++++------- .../test_commits/test_lint_staged_msg_filename_1 | 4 ++ qa/expected/test_commits/test_lint_staged_stdin_1 | 4 ++ qa/expected/test_config/test_config_from_env_1 | 4 ++ qa/expected/test_config/test_config_from_env_2 | 4 ++ .../test_config/test_config_from_file_debug_1 | 4 ++ qa/expected/test_contrib/test_contrib_rules_1 | 1 - .../test_contrib/test_contrib_rules_with_config_1 | 1 - qa/requirements.txt | 6 +- qa/shell.py | 4 +- qa/test_commits.py | 47 ++++++++++++++- qa/test_config.py | 3 +- qa/test_contrib.py | 4 +- qa/test_hooks.py | 31 +++++----- qa/test_stdin.py | 8 +-- requirements.txt | 8 +-- run_tests.sh | 3 +- setup.py | 7 ++- test-requirements.txt | 10 ++-- 56 files changed, 614 insertions(+), 160 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 docs/images/readme-gitlint.png create mode 100644 gitlint/tests/expected/cli/test_cli/test_lint_commit_1 diff --git a/.coveragerc b/.coveragerc index a2e4c8f..a120715 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,2 +1,6 @@ +[report] +fail_under = 97 + [run] -omit=*dist-packages*,*site-packages*,gitlint/tests/*,.venv/*,*virtualenv* \ No newline at end of file +branch = true +omit=*dist-packages*,*site-packages*,gitlint/tests/*,.venv/*,*virtualenv* diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..7c33438 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,14 @@ +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 diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 15eb7be..8fbda21 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -7,7 +7,7 @@ jobs: runs-on: "ubuntu-latest" strategy: matrix: - python-version: [3.6, 3.7, 3.8, 3.9, pypy3] + python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", pypy3] os: ["macos-latest", "ubuntu-latest"] steps: - uses: actions/checkout@v2 @@ -69,8 +69,11 @@ jobs: - name: Re-add git version control to code run: mv ._git .git + # 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 check run: ./run_tests.sh -g --debug + if: ${{ github.event_name != 'pull_request' }} windows-checks: runs-on: windows-latest @@ -133,5 +136,8 @@ jobs: - name: Re-add git version control to code run: Rename-Item ._git .git + # 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 check run: gitlint --debug + if: ${{ github.event_name != 'pull_request' }} diff --git a/CHANGELOG.md b/CHANGELOG.md index bb72596..dd224e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog # +## 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). + +- Python 3.10 support +- **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 +- `--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)) +- 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)) +- 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 its easily doable, which in practice usually means as long as our dependencies support it. +- Under-the-hood: dependencies updated, test and github action improvements. ## v0.15.1 (2021-04-16) ## Contributors: diff --git a/Dockerfile b/Dockerfile index 9f93206..db3642e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ # NOTE: --ulimit is required to work around a limitation in Docker # Details: https://github.com/jorisroovers/gitlint/issues/129 -FROM python:3.9-alpine +FROM python:3.10-alpine ARG GITLINT_VERSION RUN apk add git diff --git a/README.md b/README.md index 43da74c..e87dc37 100644 --- a/README.md +++ b/README.md @@ -8,12 +8,14 @@ Git commit message linter written in python (for Linux and Mac, experimental on **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 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 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! diff --git a/doc-requirements.txt b/doc-requirements.txt index 53dbf05..becd4f4 100644 --- a/doc-requirements.txt +++ b/doc-requirements.txt @@ -1 +1 @@ -mkdocs==1.1.2 \ No newline at end of file +mkdocs==1.2.2 \ No newline at end of file diff --git a/docs/configuration.md b/docs/configuration.md index 50c4e63..226ba8a 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -52,6 +52,12 @@ ignore-stdin=true # 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 + # Enable debug mode (prints more output). Disabled by default. debug=true @@ -128,7 +134,7 @@ 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(.*) +regex=(.*)release(.*) # # Ignore certain rules, you can reference them by their id or by their full name # Use 'all' to ignore all rules @@ -139,6 +145,15 @@ ignore=T1,body-min-length # 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. @@ -363,6 +378,30 @@ GITLINT_STAGED=1 gitlint # using env variable staged=true ``` +### fail-without-commits + +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. + +Default value | gitlint version | commandline flag | environment variable +---------------|------------------|---------------------------|----------------------- + false | >= 0.15.2 | `--fail-without-commits` | `GITLINT_FAIL_WITHOUT_COMMITS` + +#### Examples +```sh +# CLI +# The following will cause gitlint to hard fail (i.e. exit code > 0) +# since HEAD..HEAD is a valid but empty commit range. +gitlint --fail-without-commits --commits HEAD..HEAD +GITLINT_FAIL_WITHOUT_COMMITS=1 gitlint # using env variable +``` +```ini +#.gitlint +[general] +fail-without-commits=true +``` + ### ignore-stdin Ignore any stdin data. Sometimes useful when running gitlint in a CI server. diff --git a/docs/contributing.md b/docs/contributing.md index e58378c..d39f9e1 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -44,7 +44,9 @@ vagrant ssh Or you can choose to use your local environment: ```sh -virtualenv .venv +python -m venv .venv +. .venv/bin/activate +pip install --upgrade pip pip install -r requirements.txt -r test-requirements.txt -r doc-requirements.txt python setup.py develop ``` diff --git a/docs/images/readme-gitlint.png b/docs/images/readme-gitlint.png new file mode 100644 index 0000000..516c915 Binary files /dev/null and b/docs/images/readme-gitlint.png differ diff --git a/docs/index.md b/docs/index.md index 5b371bf..98b72de 100644 --- a/docs/index.md +++ b/docs/index.md @@ -38,12 +38,11 @@ useful throughout the years. # Pip is recommended to install the latest version pip install gitlint -# macOS -brew install gitlint -sudo port install gitlint # alternative using macports - -# Ubuntu -apt-get install gitlint +# Community maintained packages: +brew install gitlint # Homebrew (macOS) +sudo port install gitlint # Macports (macOS) +apt-get install gitlint # Ubuntu +# Other package managers, see https://repology.org/project/gitlint/versions # Docker: https://hub.docker.com/r/jorisroovers/gitlint docker run --ulimit nofile=1024 -v $(pwd):/repo jorisroovers/gitlint @@ -134,8 +133,9 @@ Options: current working directory] -C, --config FILE Config file location [default: .gitlint] -c TEXT Config flags in format .