Skip to content

Commit 1e3d3ff

Browse files
jskladanclaude
andcommitted
chore(hooks): enforce Conventional Commits with pre-commit hook
Add conventional-pre-commit hook to validate commit messages against the Conventional Commits spec already documented in CONTRIBUTING.md. Closes: #974 Signed-off-by: Josef Skladanka <jskladan@redhat.com> Co-Authored-By: Claude <claude@anthropic.com>
1 parent b5b31d9 commit 1e3d3ff

2 files changed

Lines changed: 26 additions & 6 deletions

File tree

.pre-commit-config.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
default_install_hook_types: [pre-commit, commit-msg]
2+
13
repos:
24
- repo: https://github.com/pre-commit/pre-commit-hooks
35
rev: v6.0.0
@@ -46,6 +48,23 @@ repos:
4648
- id: ruff-format
4749
types_or: [python, pyi]
4850

51+
- repo: https://github.com/compilerla/conventional-pre-commit
52+
rev: v4.4.0
53+
hooks:
54+
- id: conventional-pre-commit
55+
stages: [commit-msg]
56+
args:
57+
- feat
58+
- fix
59+
- docs
60+
- test
61+
- refactor
62+
- perf
63+
- chore
64+
- ci
65+
- build
66+
- revert
67+
4968
- repo: local
5069
hooks:
5170
- id: hatch-mypy

CONTRIBUTING.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,21 @@ git push origin feat/<short-description>
7878

7979
### Pre-commit Hook (Recommended)
8080

81-
To ensure quality checks run automatically before each commit, install the pre-commit hook that runs both linting and mypy type checking:
81+
To ensure quality checks run automatically before each commit, install the pre-commit hooks that run linting, mypy type checking, and commit message validation:
8282

8383
```bash
84-
# Install the pre-commit hook (run once after cloning)
84+
# Install pre-commit hooks (run once after cloning)
8585
hatch run lint:install-hooks
8686

87-
# The hook automatically runs a selection of linters before each commit.
87+
# The hooks automatically run linters before each commit and validate
88+
# that commit messages follow Conventional Commits format.
8889

89-
# If the hook fails, it will prevent the commit and show helpful messages
90-
# You can fix some issues automatically with:
90+
# If a hook fails, it will prevent the commit and show helpful messages.
91+
# You can fix formatting issues automatically with:
9192
hatch run lint:fix
9293
```
9394

94-
The pre-commit hook prevents commits that would fail some CI quality checks, saving time and ensuring consistent code quality.
95+
The pre-commit hooks prevent commits that would fail CI quality checks, and enforce that all commit messages follow the [Conventional Commits](https://www.conventionalcommits.org/) format documented in the [Commit Guidelines](#commit-guidelines) section.
9596

9697
---
9798

0 commit comments

Comments
 (0)