Skip to main content

commitlint is a pre-commit hook designed to lint your commit messages according to the Conventional Commits standard.

Project description

Conventional Commitlint

PyPI version CI status Downloads codecov License

commitlint is a tool that lints commit messages according to the Conventional Commits standard. It can be used in GitHub Actions and as a pre-commit hook.

Usage

GitHub Actions

If you have an existing workflow, add the following steps:

...
steps:
    ...

    - name: Conventional Commitlint
      uses: opensource-nepal/commitlint@v1

    ...

If you don't have any workflows, create a new GitHub workflow file, e.g., .github/workflows/commitlint.yaml:

name: Conventional Commitlint

on:
  push:
    branches: ["main"]
  pull_request:

jobs:
  commitlint:
    runs-on: ubuntu-latest
    name: Conventional Commitlint
    permissions:
      contents: read
      pull-requests: read
    steps:
      - name: Conventional Commitlint
        uses: opensource-nepal/commitlint@v1

Note: The commitlint GitHub Action is triggered only by push, pull_request, or pull_request_target events.

GitHub Action Permissions

The action requires read permission for the following scopes:

  • contents: read : This allows the action to list commits of the repository.
  • pull-requests: read : This allows the action to list the commits in a Pull Request.

For public repositories, these permissions are granted by default. For private repositories, you must explicitly grant them, either in:

Without these, you may encounter an error like:

Github API failed with status code 403. Response: {'message': 'Resource not accessible by integration', 'documentation_url': 'https://docs.github.com/rest/pulls/pulls#list-commits-on-a-pull-request', 'status': '403'}

GitHub Action Inputs

# Name Type Default Description
1 fail_on_error Boolean true Whether the GitHub Action should fail if commitlint detects an issue.
2 verbose Boolean false Enables verbose output.
3 token String secrets.GITHUB_TOKEN GitHub Token for fetching commits using the GitHub API.

GitHub Action Outputs

# Name Type Description
1 exit_code Integer The exit code of the commitlint step.
2 status String The outcome of the commitlint step (success or failure).

Pre-commit

  1. Add the following configuration to .pre-commit-config.yaml:

    repos:
       ...
       - repo: https://github.com/opensource-nepal/commitlint
         rev: v1.3.0
         hooks:
           - id: commitlint
       ...
    
  2. Install the commit-msg hook in your project repository:

    pre-commit install --hook-type commit-msg
    

    Running only pre-commit install will not work.

Note: Avoid using commit messages that start with #, as this may cause unexpected behavior with commitlint.

CLI (Command Line Interface)

For CLI usage, please refer to cli.md.

Contribution

We appreciate feedback and contributions to this package. To get started, please see our contribution guide.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

commitlint-1.13.3.tar.gz (24.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

commitlint-1.13.3-py3-none-any.whl (26.7 kB view details)

Uploaded Python 3

File details

Details for the file commitlint-1.13.3.tar.gz.

File metadata

  • Download URL: commitlint-1.13.3.tar.gz
  • Upload date:
  • Size: 24.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for commitlint-1.13.3.tar.gz
Algorithm Hash digest
SHA256 e92522e064010ae85b825b73923760c0e4ff34954859fec4976f3e86a342ea30
MD5 b674b6610484e1f1bd33aa616eb966e6
BLAKE2b-256 7a00e2dcd72cd76969b74e811ed06506183b00f9dd0e0f308a4f3672300a32a2

See more details on using hashes here.

Provenance

The following attestation bundles were made for commitlint-1.13.3.tar.gz:

Publisher: release-please.yml on opensource-nepal/commitlint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file commitlint-1.13.3-py3-none-any.whl.

File metadata

  • Download URL: commitlint-1.13.3-py3-none-any.whl
  • Upload date:
  • Size: 26.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for commitlint-1.13.3-py3-none-any.whl
Algorithm Hash digest
SHA256 330a9aa892b0bca9d671c5cd059755d9d48468f35095efe1be09ba667085b3f7
MD5 5f87430b77ee5ddfa7f5615d059ee5d3
BLAKE2b-256 e08aa524c54aa6a8c712ddea2da6ffbbdde93c2c4eeb8121cae2a43e266c1cea

See more details on using hashes here.

Provenance

The following attestation bundles were made for commitlint-1.13.3-py3-none-any.whl:

Publisher: release-please.yml on opensource-nepal/commitlint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page