From dcc28a9a987457acf9e2c8249a9df5e40143eba3 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 11 Mar 2023 09:03:07 +0100 Subject: Merging upstream version 0.19.1. Signed-off-by: Daniel Baumann --- .coveragerc | 6 - .devcontainer/devcontainer.json | 11 +- .devcontainer/postCreateCommand.sh | 1 + .github/dependabot.yml | 4 + .github/workflows/checks.yml | 155 ------ .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 ++++ .gitlint | 9 + .pylintrc | 48 -- CHANGELOG.md | 422 +++++++++++----- Dockerfile | 4 +- Dockerfile.dev | 17 - MANIFEST.in | 7 - README.md | 5 +- doc-requirements.txt | 1 - docs/contributing.md | 135 ++++-- docs/index.md | 14 +- gitlint-core/LICENSE | 23 +- gitlint-core/MANIFEST.in | 3 - gitlint-core/README.md | 27 +- gitlint-core/gitlint/__init__.py | 9 +- gitlint-core/gitlint/cache.py | 2 +- gitlint-core/gitlint/cli.py | 70 ++- gitlint-core/gitlint/config.py | 35 +- .../gitlint/contrib/rules/authors_commit.py | 1 - gitlint-core/gitlint/deprecation.py | 1 - gitlint-core/gitlint/display.py | 14 +- gitlint-core/gitlint/exception.py | 2 - gitlint-core/gitlint/git.py | 22 +- gitlint-core/gitlint/hooks.py | 10 +- gitlint-core/gitlint/lint.py | 4 +- gitlint-core/gitlint/options.py | 3 +- gitlint-core/gitlint/rule_finder.py | 27 +- gitlint-core/gitlint/rules.py | 38 +- gitlint-core/gitlint/shell.py | 19 +- gitlint-core/gitlint/tests/base.py | 49 +- gitlint-core/gitlint/tests/cli/test_cli.py | 101 +++- gitlint-core/gitlint/tests/cli/test_cli_hooks.py | 135 +++--- gitlint-core/gitlint/tests/config/test_config.py | 12 +- .../gitlint/tests/config/test_config_builder.py | 9 +- .../gitlint/tests/config/test_config_precedence.py | 6 +- .../gitlint/tests/config/test_rule_collection.py | 1 + .../tests/contrib/rules/test_authors_commit.py | 9 +- .../contrib/rules/test_conventional_commit.py | 6 +- .../contrib/rules/test_disallow_cleanup_commits.py | 7 +- .../tests/contrib/rules/test_signedoff_by.py | 7 +- .../gitlint/tests/contrib/test_contrib_rules.py | 4 +- .../tests/expected/cli/test_cli/test_debug_1 | 12 +- .../cli/test_cli/test_input_stream_debug_2 | 3 +- .../cli/test_cli/test_lint_multiple_commits_csv_1 | 8 + .../cli/test_cli/test_lint_staged_msg_filename_2 | 6 +- .../expected/cli/test_cli/test_lint_staged_stdin_2 | 6 +- .../tests/expected/cli/test_cli/test_named_rules_2 | 3 +- gitlint-core/gitlint/tests/git/test_git.py | 16 +- gitlint-core/gitlint/tests/git/test_git_commit.py | 22 +- gitlint-core/gitlint/tests/git/test_git_context.py | 4 +- .../gitlint/tests/rules/test_body_rules.py | 6 +- .../tests/rules/test_configuration_rules.py | 26 +- .../gitlint/tests/rules/test_meta_rules.py | 5 +- gitlint-core/gitlint/tests/rules/test_rules.py | 13 +- .../gitlint/tests/rules/test_title_rules.py | 14 +- .../gitlint/tests/rules/test_user_rules.py | 23 +- .../tests/samples/user_rules/my_commit_rules.py | 4 +- .../samples/user_rules/parent_package/__init__.py | 2 +- gitlint-core/gitlint/tests/test_cache.py | 2 +- gitlint-core/gitlint/tests/test_deprecation.py | 5 +- gitlint-core/gitlint/tests/test_display.py | 5 +- gitlint-core/gitlint/tests/test_hooks.py | 32 +- gitlint-core/gitlint/tests/test_lint.py | 7 +- gitlint-core/gitlint/tests/test_options.py | 17 +- gitlint-core/gitlint/tests/test_utils.py | 4 +- gitlint-core/gitlint/utils.py | 36 +- gitlint-core/pyproject.toml | 71 +++ gitlint-core/setup.cfg | 2 - gitlint-core/setup.py | 109 ----- hatch_build.py | 13 + pyproject.toml | 202 +++++++- qa/base.py | 43 +- .../test_commits/test_lint_staged_msg_filename_1 | 3 +- qa/expected/test_commits/test_lint_staged_stdin_1 | 3 +- qa/expected/test_config/test_config_from_env_1 | 3 +- qa/expected/test_config/test_config_from_env_2 | 3 +- .../test_config/test_config_from_file_debug_1 | 3 +- qa/expected/test_gitlint/test_commit_binary_file_1 | 3 +- 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 + .../test_user_defined_rules_examples_2 | 1 + qa/requirements.txt | 4 - qa/samples/user_rules/extra/extra_rules.py | 10 +- qa/shell.py | 83 ++-- qa/test_commits.py | 10 +- qa/test_config.py | 10 +- qa/test_contrib.py | 3 +- qa/test_gitlint.py | 14 +- qa/test_hooks.py | 22 +- qa/test_named_rules.py | 2 +- qa/test_rules.py | 61 +++ qa/test_stdin.py | 12 +- qa/test_user_defined.py | 5 +- qa/utils.py | 46 +- requirements.txt | 4 - run_tests.sh | 532 --------------------- setup.cfg | 2 - setup.py | 64 --- test-requirements.txt | 10 - tools/changelog.py | 51 ++ tools/stats.sh | 45 ++ 111 files changed, 2060 insertions(+), 1678 deletions(-) delete mode 100644 .coveragerc delete mode 100644 .github/workflows/checks.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 .gitlint delete mode 100644 .pylintrc delete mode 100644 Dockerfile.dev delete mode 100644 MANIFEST.in delete mode 100644 doc-requirements.txt mode change 120000 => 100644 gitlint-core/LICENSE delete mode 100644 gitlint-core/MANIFEST.in mode change 120000 => 100644 gitlint-core/README.md create mode 100644 gitlint-core/gitlint/tests/expected/cli/test_cli/test_lint_multiple_commits_csv_1 create mode 100644 gitlint-core/pyproject.toml delete mode 100644 gitlint-core/setup.cfg delete mode 100644 gitlint-core/setup.py create mode 100644 hatch_build.py 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 delete mode 100644 qa/requirements.txt create mode 100644 qa/test_rules.py delete mode 100644 requirements.txt delete mode 100755 run_tests.sh delete mode 100644 setup.cfg delete mode 100644 setup.py delete mode 100644 test-requirements.txt create mode 100755 tools/changelog.py create mode 100755 tools/stats.sh diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index 9da615c..0000000 --- a/.coveragerc +++ /dev/null @@ -1,6 +0,0 @@ -[report] -fail_under = 97 - -[run] -branch = true -omit=*dist-packages*,*site-packages*,gitlint-core/gitlint/tests/*,.venv/*,*virtualenv* diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 5889037..65fcc1c 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -22,7 +22,11 @@ "settings": { "python.defaultInterpreterPath": "/usr/local/bin/python", "python.linting.enabled": true, - "python.linting.pylintEnabled": 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", @@ -31,12 +35,13 @@ "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", - "python.linting.pylintPath": "/usr/local/py-utils/bin/pylint" }, // Add the IDs of extensions you want installed when the container is created. "extensions": [ "ms-python.python", - "ms-python.vscode-pylance" + "ms-python.vscode-pylance", + "charliermarsh.ruff", + "tamasfe.even-better-toml" ] } }, diff --git a/.devcontainer/postCreateCommand.sh b/.devcontainer/postCreateCommand.sh index 4bbaf05..e2f0f76 100755 --- a/.devcontainer/postCreateCommand.sh +++ b/.devcontainer/postCreateCommand.sh @@ -1,6 +1,7 @@ #!/bin/sh -x brew install asdf +brew install hatch source "$(brew --prefix asdf)/libexec/asdf.sh" # Install latest python diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 7c33438..a781b54 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -12,3 +12,7 @@ updates: directory: / schedule: interval: daily + - package-ecosystem: pip + directory: /gitlint-core + schedule: + interval: daily diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml deleted file mode 100644 index 39b3782..0000000 --- a/.github/workflows/checks.yml +++ /dev/null @@ -1,155 +0,0 @@ -name: Tests and Checks - -on: [push, pull_request] - -jobs: - checks: - runs-on: "ubuntu-latest" - strategy: - matrix: - python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", pypy-3.9] - os: ["macos-latest", "ubuntu-latest"] - steps: - - uses: actions/checkout@v3.0.2 - 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@v4.2.0 - with: - python-version: ${{ matrix.python-version }} - - - name: Install requirements - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - pip install -r test-requirements.txt - - - name: Unit Tests - run: ./run_tests.sh - - # Coveralls integration doesn't properly work at this point, also see below - # - name: Coveralls - # env: - # COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} - # run: coveralls - - # Patch the commit-msg hook to make it work in GH CI - # Specifically, within the commit-msg hook, wrap the invocation of gitlint with `script` - - - name: Patch commit-msg hook - run: | - # Escape " to \" - sed -i -E '/^gitlint/ s/"/\\"/g' gitlint-core/gitlint/files/commit-msg - # Replace `gitlint ` with `script -e -q -c "gitlint "` - sed -i -E 's/^gitlint(.*)/script -e -q -c "\0"/' gitlint-core/gitlint/files/commit-msg - - - name: Integration Tests - run: ./run_tests.sh -i - - # Gitlint no longer uses `sh` by default, but for now we're still supporting the manual enablement of it. - # By setting GITLINT_USE_SH_LIB=1, we test whether this still works. - - name: Integration Tests (GITLINT_USE_SH_LIB=1) - env: - GITLINT_USE_SH_LIB: 1 - run: ./run_tests.sh -i - - - name: Code formatting (black) - run: ./run_tests.sh -f - - - name: PyLint - run: ./run_tests.sh -l - - - name: Build tests - run: ./run_tests.sh --build - - # Coveralls GH Action currently doesn't support current non-LCOV reporting format - # For now, still using Travis for unit test coverage reporting - # https://github.com/coverallsapp/github-action/issues/30 - # - name: Coveralls - # uses: coverallsapp/github-action@master - # 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 - - # 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 - strategy: - matrix: - python-version: ["3.10"] - steps: - - uses: actions/checkout@v3.0.2 - 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@v4.2.0 - with: - python-version: ${{ matrix.python-version }} - - - name: "Upgrade pip on Python 3" - if: matrix.python-version == '3.10' - run: python -m pip install --upgrade pip - - - name: Install requirements - run: | - pip install -r requirements.txt - pip install -r test-requirements.txt - - - name: gitlint --version - run: gitlint --version - - - name: Tests (sanity) - run: tools\windows\run_tests.bat "gitlint-core\gitlint\tests\cli\test_cli.py::CLITests::test_lint" - - - name: Tests (ignore cli\*) - run: pytest --ignore gitlint-core\gitlint\tests\cli -rw -s gitlint-core - - - name: Tests (test_cli.py only - continue-on-error:true) - run: tools\windows\run_tests.bat "gitlint-core\gitlint\tests\cli\test_cli.py" - continue-on-error: true # Known to fail at this point - - - name: Tests (all - continue-on-error:true) - run: tools\windows\run_tests.bat - continue-on-error: true # Known to fail at this point - - - name: Integration tests (continue-on-error:true) - run: pytest -rw -s qa - continue-on-error: true # Known to fail at this point - - - name: Code formatting (black) - run: black . - - - name: PyLint - run: pylint gitlint-core\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 - - # 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/.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/.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/.pylintrc b/.pylintrc deleted file mode 100644 index dc54455..0000000 --- a/.pylintrc +++ /dev/null @@ -1,48 +0,0 @@ -# The format of this file isn't really documented; just use --generate-rcfile -[MASTER] - -[Messages Control] -# C0111: Don't require docstrings on every method -# W0511: TODOs in code comments are fine. -# W0142: *args and **kwargs are fine. -# W0223: abstract methods don't need to be overwritten (i.e. when overwriting a Django REST serializer) -# W0622: Redefining id is fine. -# R0901: Too many ancestors (i.e. when subclassing test classes) -# R0801: Similar lines in files -# I0011: Informational: locally disabled pylint -# I0013: Informational: Ignoring entire file -disable=bad-option-value,C0111,W0511,W0142,W0622,W0223,W0212,R0901,R0801,I0011,I0013,anomalous-backslash-in-string,useless-object-inheritance,unnecessary-pass - -[Format] -max-line-length=120 - -[Basic] -# Variable names can be 1 to 31 characters long, with lowercase and underscores -variable-rgx=[a-z_][a-z0-9_]{0,30}$ - -# Argument names can be 2 to 31 characters long, with lowercase and underscores -argument-rgx=[a-z_][a-z0-9_]{1,30}$ - -# Method names should be at least 3 characters long -# and be lower-cased with underscores -method-rgx=([a-z_][a-z0-9_]{2,50}|setUp|tearDown)$ - -# Allow 'id' as variable name everywhere -good-names=id,c,_ - -bad-names=__author__ - -# Ignore all variables that start with an underscore (e.g. unused _request variable in a view) -dummy-variables-rgx=_ - -[Design] -max-public-methods=100 -min-public-methods=0 -# Maximum number of attributes of a class -max-attributes=15 -max-args=10 -max-locals=20 - -[Typecheck] -# Allow the use of the Django 'objects' members -generated-members=sh.git diff --git a/CHANGELOG.md b/CHANGELOG.md index 091b2a4..f26f670 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,28 +1,80 @@ -# Changelog # +# Changelog +This file documents notable changes introduced in gitlint releases. -## v0.18.0 (2022-11-16) ## +# 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: + +## 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: + +## 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: + +## 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) -- Under-the-hood: + +## 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)) @@ -32,63 +84,75 @@ Special thanks to all contributors for this release - details inline! - 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) ## +# 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) ## + +# 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 -- **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 +- 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)) -- Bugfixes: + +## 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)) -- 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. -- Under-the-hood: dependencies updated, test and github action improvements. -## v0.15.1 (2021-04-16) ## + +## 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: +## 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) ## + +# 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). -**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.** +## General -Other call-outs: +- **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). -- Bugfix: Gitlint now properly handles exceptions when using its built-in commit-msg hook ([#166](https://github.com/jorisroovers/gitlint/issues/166)). + +## 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) ## +# 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 -- **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/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. @@ -96,45 +160,75 @@ the lines in a commit message body ([#126](https://github.com/jorisroovers/gitli - 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) +## 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) +# 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)) +## 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. -- Bugfixes: +- **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 -- Under-the-hood: dependencies updated, unit and integration test improvements, migrated from TravisCI to Github Actions. -## v0.12.0 (2019-07-15) ## +## 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. @@ -143,40 +237,40 @@ Special thanks to all contributors for this release, in particular [@rogalksi](h - 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)) -- Bugfixes: + +## 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) -- Under-the-hood: dependencies updated, experimental Dockerfile, github issue template. -## v0.11.0 (2019-03-13) ## +## 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) ## +# 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. -**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.** +## 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.** -Full Changelog: - -- **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. +## 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)). @@ -186,18 +280,26 @@ a line in a commit message body. - 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). -- 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) ## +## 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. -- 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). +## 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, @@ -212,68 +314,89 @@ and [AlexMooney](https://github.com/AlexMooney) for their contributions. - **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)) -- Bugfix: [#37: Prevent Commas in text fields from breaking git log printing](https://github.com/jorisroovers/gitlint/issues/37) + +## 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) ## +# 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: + +## 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) ## +# 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! -- 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. - -## v0.8.0 (2016-12-30) ## + +# 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. -- 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 -- 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. -- Various documentation improvements -- 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: +## 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) @@ -283,53 +406,68 @@ 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) ## +# 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. -- 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*. +## 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`. -- 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) - - [#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. -- Development: initial set of integration tests. Test gitlint end-to-end after it is installed. -- Development: pylint compliance for python 2.7 -## v0.6.1 (2015-11-22) ## +## 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 -- Fix: `install-hook` and `generate-config` commands not working when gitlint is installed from pypi. +## 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.0 (2015-11-22) ## +# 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/]() -- 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. + +## 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 -- Fix: `--config` option no longer accepts directories as value -- Development: unit tests are now ran using py.test -## v0.5.0 (2015-10-04) ## +## 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 -- 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. @@ -338,38 +476,66 @@ requests. - Violations are now sorted by line number first and then by rule id (previously the order of violations on the same line was arbitrary). -## v0.4.1 (2015-09-19) ## +## Rules +- New Rule: `title-match-regex`. Details can be found in the + [Rules section of the documentation](http://jorisroovers.github.io/gitlint/rules/). -- Internal fix: added missing comma to setup.py which prevented pypi upload +# v0.4.1 (2015-09-19) -## v0.4.0 (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/). -- 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. + +## 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) ## -- `title-must-not-contain-word` now has a `words` option that can be used to specify which words should not - occur in the title +# v0.3.0 (2015-09-11) +## Features - gitlint violations are now printed to the stderr instead of stdout -- Various minor bugfixes - 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) ## - - Rules can now have their behavior configured through options. +# 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. - - Under-the-hood: The codebase now has a basic level of unit test coverage, increasing overall quality assurance + +## Development + - 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 +# v0.1.1 (2015-09-08) + +## Bugfixes +- Added missing `sh` dependency + +# v0.1.0 (2015-09-08) -## 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 diff --git a/Dockerfile b/Dockerfile index f560c44..641296e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,3 @@ -# User-facing Dockerfile. For development, see Dockerfile.dev and ./run_tests.sh -h - # To lint your current working directory: # docker run --ulimit nofile=1024 -v $(pwd):/repo jorisroovers/gitlint @@ -9,7 +7,7 @@ # NOTE: --ulimit is required to work around a limitation in Docker # Details: https://github.com/jorisroovers/gitlint/issues/129 -FROM python:3.11.0-alpine +FROM python:3.11.2-alpine ARG GITLINT_VERSION RUN apk add git diff --git a/Dockerfile.dev b/Dockerfile.dev deleted file mode 100644 index 5cd1739..0000000 --- a/Dockerfile.dev +++ /dev/null @@ -1,17 +0,0 @@ -# Note: development using the local Dockerfile is still work-in-progress -# Getting started: http://jorisroovers.github.io/gitlint/contributing/ -ARG python_version_dotted - -FROM python:${python_version_dotted}-stretch - -RUN apt-get update -# software-properties-common contains 'add-apt-repository' -RUN apt-get install -y git silversearcher-ag jq curl - -ADD . /gitlint -WORKDIR /gitlint - -RUN pip install --ignore-requires-python -r requirements.txt -RUN pip install --ignore-requires-python -r test-requirements.txt - -CMD ["/bin/bash"] diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index ad3da8a..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,7 +0,0 @@ -include README.md -include LICENSE -exclude Vagrantfile -exclude *.yml *.sh *.txt -recursive-exclude examples * -recursive-exclude gitlint-core * -recursive-exclude qa * diff --git a/README.md b/README.md index ecf8298..05787be 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,16 @@ # 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 (for Linux and Mac, experimental on Windows), checks your commit messages for style. +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 ## diff --git a/doc-requirements.txt b/doc-requirements.txt deleted file mode 100644 index 40febbe..0000000 --- a/doc-requirements.txt +++ /dev/null @@ -1 +0,0 @@ -mkdocs==1.4.1 \ No newline at end of file diff --git a/docs/contributing.md b/docs/contributing.md index 254e856..d111bc6 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -3,13 +3,14 @@ We'd love for you to contribute to gitlint. Thanks for your interest! The [source-code and issue tracker](https://github.com/jorisroovers/gitlint) are hosted on Github. -Often it takes a while for us (well, actually just [me](https://github.com/jorisroovers)) to get back to you -(sometimes up to a few months, this is a hobby project), but rest assured that we read your message and appreciate -your interest! -We maintain a [loose project plan on github projects](https://github.com/users/jorisroovers/projects/1/), but -that's open to a lot of change and input. +!!! note + Often it takes a while for us (well, actually just [me](https://github.com/jorisroovers)) to get back to you + (sometimes up to a few months, this is a hobby project), but rest assured that we read your message and appreciate + your interest! + We maintain a [loose project plan on github projects](https://github.com/users/jorisroovers/projects/1/), but + that's open to a lot of change and input. -## Guidelines +## Overall Guidelines When contributing code, please consider all the parts that are typically required: @@ -26,28 +27,46 @@ can make it as part of a release. **Gitlint commits and pull requests are gated code-review**. If you can already include them as part of your PR, it's a huge timesaver for us and it's likely that your PR will be merged and released a lot sooner. -It's also a good idea to open an issue before submitting a PR for non-trivial changes, so we can discuss what you have -in mind before you spend the effort. Thanks! +!!! important + It's a good idea to open an issue before submitting a PR for non-trivial changes, so we can discuss what you have + in mind before you spend the effort. Thanks! -!!! Important - **On the topic of releases**: Gitlint releases typically go out when there's either enough new features and fixes - to make it worthwhile or when there's a critical fix for a bug that fundamentally breaks gitlint. While the amount - of overhead of doing a release isn't huge, it's also not zero. In practice this means that it might take weeks - or months before merged code actually gets released - we know that can be frustrating but please understand it's - a well-considered trade-off based on available time. +## Releases +Gitlint releases typically go out when there's either enough new features and fixes +to make it worthwhile or when there's a critical fix for a bug that fundamentally breaks gitlint. -## Local setup +While the amount of overhead of doing a release isn't huge, it's also not zero. In practice this means that it might +take weeks or months before merged code actually gets released - we know that can be frustrating but please +understand it's a well-considered trade-off based on available time. -To install gitlint for local development: +### Dev Builds +While final releases are usually months apart, we do dev builds on every commit to `main`: +- **gitlint**: [https://pypi.org/project/gitlint/#history](https://pypi.org/project/gitlint/#history) +- **gitlint-core**: [https://pypi.org/project/gitlint-core/#history](https://pypi.org/project/gitlint-core/#history) + +It usually takes about 5 min after merging a PR to `main` for new dev builds to show up. Note that the installation +of a recently published version can still fail for a few minutes after a new version shows up on PyPI while the package +is replicated to all download mirrors. + +To install a dev build of gitlint: ```sh -python -m venv .venv -. .venv/bin/activate -pip install -r requirements.txt -r test-requirements.txt -r doc-requirements.txt -python setup.py develop +# Find latest dev build on https://pypi.org/project/gitlint/#history +pip install gitlint=="0.19.0.dev68" ``` -## Github Devcontainer + +## Environment setup +### Local setup + +Gitlint uses [hatch](https://hatch.pypa.io/latest/) for project management. +You do not need to setup a `virtualenv`, hatch will take care of that for you. + +```sh +pip install hatch +``` + +### Github Devcontainer We provide a devcontainer on github to make it easier to get started with gitlint development using VSCode. @@ -59,12 +78,6 @@ To start one, click the plus button under the *Code* dropdown on ![Gitlint Dev Container Instructions](images/dev-container.png) -After setup has finished, you should be able to just activate the virtualenv in the home dir and run the tests: -```sh -. ~/.venv/bin/activate -./run_tests.sh -``` - By default we have python 3.11 installed in the dev container, but you can also use [asdf](https://asdf-vm.com/) (preinstalled) to install additional python versions: @@ -83,27 +96,43 @@ asdf list python ## Running tests ```sh -./run_tests.sh # run unit tests and print test coverage -./run_tests.sh gitlint-core/gitlint/tests/rules/test_body_rules.py::BodyRuleTests::test_body_missing # run a single test -pytest -k test_body_missing # Alternative way to run a specific test by invoking pytest directly with a keyword expression -./run_tests.sh --no-coverage # run unit tests without test coverage -./run_tests.sh --collect-only --no-coverage # Only collect, don't run unit tests -./run_tests.sh --integration # Run integration tests (requires that you have gitlint installed) -./run_tests.sh --build # Run build tests (=build python package) -./run_tests.sh --format # format checks (black) -./run_tests.sh --stats # print some code stats -./run_tests.sh --git # inception: run gitlint against itself -./run_tests.sh --lint # run pylint checks -./run_tests.sh --all # Run unit, integration, format and gitlint checks +# Gitlint +hatch run dev:gitlint # run the local source copy of gitlint +hatch run dev:gitlint --version # This is just the gitlint binary, any flag will work +hatch run dev:gitlint --debug + +# Unit tests +hatch run test:unit-tests # run unit tests +hatch run test:unit-tests gitlint-core/gitlint/tests/rules/test_body_rules.py::BodyRuleTests::test_body_missing # run a single test +hatch run test:unit-tests -k test_body_missing_merge_commit # Run a specific tests using a pytest keyword expression +hatch run test:unit-tests-no-cov # run unit tests without test coverage + +# Integration tests +hatch run qa:install-local # One-time install: install the local gitlint source copy for integration testing +hatch run qa:integration-tests # Run integration tests + +# Formatting check (black) +hatch run test:format # Run formatting checks + +# Linting (ruff) +hatch run test:lint # Run Ruff + +# Project stats +hatch run test:stats ``` -## Formatting +## Autoformatting and autofixing We use [black](https://black.readthedocs.io/en/stable/) for code formatting. -To use it, just run black against the code you modified: ```sh -black . # format all python code -black gitlint-core/gitlint/lint.py # format a specific file +hatch run test:autoformat # format all python code +hatch run test:autoformat gitlint-core/gitlint/lint.py # format a specific file +``` + +We use [ruff](https://github.com/charliermarsh/ruff) for linting, it can autofix many of the issue it finds +(although not always perfect). +```sh +hatch run test:autofix # Attempt to fix linting issues ``` ## Documentation @@ -111,8 +140,7 @@ We use [mkdocs](https://www.mkdocs.org/) for generating our documentation from m To use it: ```sh -pip install -r doc-requirements.txt # install doc requirements -mkdocs serve +hatch run docs:serve ``` Then access the documentation website on [http://localhost:8000](). @@ -133,17 +161,18 @@ to split gitlint in 2 packages. ![Gitlint package structure](images/gitlint-packages.png) -### Packaging description - -To see the package description in HTML format +To build the packages locally: ```sh -pip install docutils -export LC_ALL=en_US.UTF-8 -export LANG=en_US.UTF-8 -python setup.py --long-description | rst2html.py > output.html +# gitlint +hatch build +hatch clean # cleanup + +# gitlint-core +cd gitlint-core +hatch build +hatch clean # cleanup ``` - ## Tools We keep a small set of scripts in the `tools/` directory: diff --git a/docs/index.md b/docs/index.md index 801a16e..b735b6b 100644 --- a/docs/index.md +++ b/docs/index.md @@ -7,7 +7,7 @@ Great for use as a [commit-msg git hook](#using-gitlint-as-a-commit-msg-hook) or !!! note - **Gitlint support for Windows is experimental**, and [there are some known issues](https://github.com/jorisroovers/gitlint/issues?q=is%3Aissue+is%3Aopen+label%3Awindows). + **Gitlint works on Windows**, but [there are some known issues](https://github.com/jorisroovers/gitlint/issues?q=is%3Aissue+is%3Aopen+label%3Awindows). Also, gitlint is not the only git commit message linter out there, if you are looking for an alternative written in a different language, have a look at [fit-commit](https://github.com/m1foley/fit-commit) (Ruby), @@ -15,7 +15,7 @@ Great for use as a [commit-msg git hook](#using-gitlint-as-a-commit-msg-hook) or !!! important - **Gitlint no longer supports Python 2.7 and Python 3.5 as they [have reached End-Of-Life](https://endoflife.date/python). The last gitlint version to support Python 2.7 and Python 3.5 is `0.14.0` (released on October 24th, 2020).** + **Gitlint requires Python 3.7 (or above). For Python 2.7 and Python 3.5 use `gitlint==0.14.0` (released 2020-10-24), for Python 3.6 `gitlint==0.18.0` (released 2022-11-16).** ## Features - **Commit message hook**: [Auto-trigger validations against new commit message right when you're committing](#using-gitlint-as-a-commit-msg-hook). Also [works with pre-commit](#using-gitlint-through-pre-commit). @@ -30,7 +30,8 @@ useful throughout the years. - **User-defined rules:** Want to do more then what gitlint offers out of the box? Write your own [user defined rules](user_defined_rules.md). - **Full unicode support:** Lint your Russian, Chinese or Emoji commit messages with ease! - **Production-ready:** Gitlint checks a lot of the boxes you're looking for: actively maintained, high unit test coverage, integration tests, - python code standards (pep8, pylint), good documentation, widely used, proven track record. + python code standards ([black](https://github.com/psf/black), [ruff](https://github.com/charliermarsh/ruff)), + good documentation, widely used, proven track record. ## Getting Started ### Installation @@ -271,7 +272,7 @@ If you want to lint more commits you can modify the `gitlint-ci` hook like so: ```yaml - repo: https://github.com/jorisroovers/gitlint - rev: v0.17.0 + rev: # insert ref, e.g. v0.18.0 hooks: - id: gitlint - id: gitlint-ci @@ -317,12 +318,14 @@ gitlint --commits mybranch # Lint all commits that are different between a branch and your main branch gitlint --commits "main..mybranch" # Use git's special references -gitlint --commits "origin..HEAD" +gitlint --commits "origin/main..HEAD" # You can also pass multiple, comma separated commit hashes: gitlint --commits 019cf40,c50eb150,d6bc75a # These can include special references as well gitlint --commits HEAD~1,mybranch-name,origin/main,d6bc75a +# You can also lint a single commit with --commits: +gitling --commits 019cf40, ``` The `--commits` flag takes a **single** refspec argument or commit range. Basically, any range that is understood @@ -331,6 +334,7 @@ by [git rev-list](https://git-scm.com/docs/git-rev-list) as a single argument wi Alternatively, you can pass `--commits` a comma-separated list of commit hashes (both short and full-length SHAs work, as well as special references such as `HEAD` and branch names). Gitlint will treat these as pointers to **single** commits and lint these in the order you passed. +`--commits` also accepts a single commit SHA with a trailing comma. For cases where the `--commits` option doesn't provide the flexibility you need, you can always use a simple shell script to lint an arbitrary set of commits, like shown in the example below. diff --git a/gitlint-core/LICENSE b/gitlint-core/LICENSE deleted file mode 120000 index ea5b606..0000000 --- a/gitlint-core/LICENSE +++ /dev/null @@ -1 +0,0 @@ -../LICENSE \ No newline at end of file diff --git a/gitlint-core/LICENSE b/gitlint-core/LICENSE new file mode 100644 index 0000000..122bd28 --- /dev/null +++ b/gitlint-core/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/gitlint-core/MANIFEST.in b/gitlint-core/MANIFEST.in deleted file mode 100644 index 375cec1..0000000 --- a/gitlint-core/MANIFEST.in +++ /dev/null @@ -1,3 +0,0 @@ -include README.md -include LICENSE -recursive-exclude gitlint/tests * diff --git a/gitlint-core/README.md b/gitlint-core/README.md deleted file mode 120000 index 32d46ee..0000000 --- a/gitlint-core/README.md +++ /dev/null @@ -1 +0,0 @@ -../README.md \ No newline at end of file diff --git a/gitlint-core/README.md b/gitlint-core/README.md new file mode 100644 index 0000000..dfbbe7f --- /dev/null +++ b/gitlint-core/README.md @@ -0,0 +1,26 @@ +# Gitlint-core + +# 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/gitlint-core/gitlint/__init__.py b/gitlint-core/gitlint/__init__.py index ad6b570..a2339fd 100644 --- a/gitlint-core/gitlint/__init__.py +++ b/gitlint-core/gitlint/__init__.py @@ -1 +1,8 @@ -__version__ = "0.19.0dev" +import sys + +if sys.version_info >= (3, 8): + from importlib import metadata # pragma: nocover +else: + import importlib_metadata as metadata # pragma: nocover + +__version__ = metadata.version("gitlint-core") diff --git a/gitlint-core/gitlint/cache.py b/gitlint-core/gitlint/cache.py index b84c904..a3dd0c8 100644 --- a/gitlint-core/gitlint/cache.py +++ b/gitlint-core/gitlint/cache.py @@ -13,7 +13,7 @@ class PropertyCache: return self._cache[cache_key] -def cache(original_func=None, cachekey=None): # pylint: disable=unused-argument +def cache(original_func=None, cachekey=None): """Cache decorator. Caches function return values. Requires the parent class to extend and initialize PropertyCache. Usage: diff --git a/gitlint-core/gitlint/cli.py b/gitlint-core/gitlint/cli.py index 387072e..619f006 100644 --- a/gitlint-core/gitlint/cli.py +++ b/gitlint-core/gitlint/cli.py @@ -1,22 +1,22 @@ -# pylint: disable=bad-option-value,wrong-import-position -# We need to disable the import position checks because of the windows check that we need to do below import copy import logging import os import platform import stat import sys + import click import gitlint -from gitlint.lint import GitLinter +from gitlint import hooks from gitlint.config import LintConfigBuilder, LintConfigError, LintConfigGenerator -from gitlint.deprecation import LOG as DEPRECATED_LOG, DEPRECATED_LOG_FORMAT +from gitlint.deprecation import DEPRECATED_LOG_FORMAT +from gitlint.deprecation import LOG as DEPRECATED_LOG +from gitlint.exception import GitlintError from gitlint.git import GitContext, GitContextError, git_version -from gitlint import hooks +from gitlint.lint import GitLinter from gitlint.shell import shell from gitlint.utils import LOG_FORMAT -from gitlint.exception import GitlintError # Error codes GITLINT_SUCCESS = 0 @@ -40,8 +40,6 @@ LOG = logging.getLogger("gitlint.cli") class GitLintUsageError(GitlintError): """Exception indicating there is an issue with how gitlint is used.""" - pass - def setup_logging(): """Setup gitlint logging""" @@ -49,7 +47,7 @@ def setup_logging(): # Root log, mostly used for debug root_log = logging.getLogger("gitlint") root_log.propagate = False # Don't propagate to child loggers, the gitlint root logger handles everything - root_log.setLevel(logging.ERROR) + root_log.setLevel(logging.WARN) handler = logging.StreamHandler() formatter = logging.Formatter(LOG_FORMAT) handler.setFormatter(formatter) @@ -69,10 +67,11 @@ def log_system_info(): LOG.debug("Git version: %s", git_version()) LOG.debug("Gitlint version: %s", gitlint.__version__) LOG.debug("GITLINT_USE_SH_LIB: %s", os.environ.get("GITLINT_USE_SH_LIB", "[NOT SET]")) - LOG.debug("DEFAULT_ENCODING: %s", gitlint.utils.DEFAULT_ENCODING) + LOG.debug("TERMINAL_ENCODING: %s", gitlint.utils.TERMINAL_ENCODING) + LOG.debug("FILE_ENCODING: %s", gitlint.utils.FILE_ENCODING) -def build_config( # pylint: disable=too-many-arguments +def build_config( target, config_path, c, @@ -172,11 +171,9 @@ def build_git_context(lint_config, msg_filename, commit_hash, refspec): from_commit_msg = GitContext.from_commit_msg if lint_config.staged: LOG.debug("Fetching additional meta-data from staged commit") - from_commit_msg = ( - lambda message: GitContext.from_staged_commit( # pylint: disable=unnecessary-lambda-assignment - message, lint_config.target - ) - ) + + def from_commit_msg(message): + return GitContext.from_staged_commit(message, lint_config.target) # Order of precedence: # 1. Any data specified via --msg-filename @@ -208,7 +205,7 @@ def build_git_context(lint_config, msg_filename, commit_hash, refspec): if refspec: # 3.1.1 Not real refspec, but comma-separated list of commit hashes if "," in refspec: - commit_hashes = [hash.strip() for hash in refspec.split(",")] + commit_hashes = [hash.strip() for hash in refspec.split(",") if hash] return GitContext.from_local_repository(lint_config.target, commit_hashes=commit_hashes) # 3.1.2 Real refspec return GitContext.from_local_repository(lint_config.target, refspec=refspec) @@ -247,43 +244,43 @@ class ContextObj: # fmt: off -@click.group(invoke_without_command=True, context_settings={'max_content_width': 120}, +@click.group(invoke_without_command=True, context_settings={"max_content_width": 120}, epilog="When no COMMAND is specified, gitlint defaults to 'gitlint lint'.") -@click.option('--target', envvar='GITLINT_TARGET', +@click.option("--target", envvar="GITLINT_TARGET", type=click.Path(exists=True, resolve_path=True, file_okay=False, readable=True), help="Path of the target git repository. [default: current working directory]") -@click.option('-C', '--config', envvar='GITLINT_CONFIG', +@click.option("-C", "--config", envvar="GITLINT_CONFIG", type=click.Path(exists=True, dir_okay=False, readable=True, resolve_path=True), help=f"Config file location [default: {DEFAULT_CONFIG_FILE}]") -@click.option('-c', multiple=True, +@click.option("-c", multiple=True, help="Config flags in format .