commitlint
commitlint is a tool designed to lint your commit messages according to the Conventional Commits standard for your pre-commit hook and GitHub Actions.
How to use
For pre-commit
-
Add the following configuration on
.pre-commit-config.yaml.repos: ... - repo: https://github.com/opensource-nepal/commitlint rev: v0.2.1 hooks: - id: commitlint ...
-
Install the
commit-msghook in your project repo:pre-commit install --hook-type commit-msg
NOTE: Installing using only
pre-commit installwill not work.
For github-actions
If you have any existing workflows, add the following steps:
...
steps:
...
- name: Run commitlint
uses: opensource-nepal/commitlint@v0.2.1
...
If you don't have any workflows, create a new GitHub workflow, e.g. .github/workflows/commitlint.yaml.
name: Commitlint
on:
push:
branches: ['main']
pull_request:
jobs:
commitlint:
runs-on: ubuntu-latest
name: Commitlint
steps:
- uses: actions/checkout@v4
- name: Run commitlint
uses: opensource-nepal/commitlint@v0.2.1
NOTE: commitlint GitHub Actions will only be triggered by "push" or "pull_request" events.
GitHub Action Inputs
| # | Name | Type | Default | Description |
|---|---|---|---|---|
| 1 | fail_on_error | Boolean | true | Determines whether the GitHub Action should fail if commitlint fails. |
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. Possible values: 'success' or 'failure'. |
CLI (Command Line Interface)
Installation
pip install commitlint
Usage
$ commitlint --help
usage: commitlint [-h] [-V] [--file FILE] [--hash HASH] [--from-hash FROM_HASH] [--to-hash TO_HASH] [--skip-detail] [commit_message]
Check if a commit message follows the conventional commit format.
positional arguments:
commit_message The commit message to be checked.
optional arguments:
-h, --help show this help message and exit
-V, --version show program's version number and exit
--file FILE Path to a file containing the commit message.
--hash HASH Commit hash
--from-hash FROM_HASH
From commit hash
--to-hash TO_HASH To commit hash
--skip-detail Skip the detailed error message check
Examples
Check commit message directly:
$ commitlint "chore: my commit message"
Check commit message from file:
$ commitlint --file /foo/bar/commit-message.txt
Check commit message of a hash:
$ commitlint --hash 9a8c08173
Check commit message of a hash range:
$ commitlint --from-hash 00bf73fef7 --to-hash d6301f1eb0
Check commit message skipping the detail check:
$ commitlint --skip-detail "chore: my commit message"
# or
$ commitlint --skip-detail --hash 9a8c08173
Version check:
$ commitlint --version
# or
$ commitlint -V
Contribution
We appreciate feedback and contribution to this package. To get started please see our contribution guide.
Metadata
Release files for commitlint-autorelease 1.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| commitlint_autorelease-1.3.1.tar.gz | 25.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| commitlint_autorelease-1.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 49.8 kB
Release files / commitlint_autorelease-1.3.1.tar.gz
| Download URL | commitlint_autorelease-1.3.1.tar.gz |
|---|---|
| Size | 25.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
af46a521f172b435f74789e9bd4c470eb129eb158b034a9686d5d92de8c752cf
|
|
BLAKE2b-256 checksum How to use checksums |
c521d423889b358775f85a64deb94f94946804238f321b2ffad98502144fd81f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.0.0 CPython/3.12.3
|
Release files / commitlint_autorelease-1.3.1-py3-none-any.whl
| Download URL | commitlint_autorelease-1.3.1-py3-none-any.whl |
|---|---|
| Size | 24.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3fc5eebadcc9cd6ac7a64008c6cbcced235b9795b5da10ed8a6ea19ad5c0541f
|
|
BLAKE2b-256 checksum How to use checksums |
eb91a1b6fd19fd78429da3e121a735a907c61600e77abb8a3845983789245668
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.0.0 CPython/3.12.3
|