chore: harmonize gitlint with commitlint standards

- Enforce lowercase descriptions and proper scope validation
- Expand automated commit ignoring for merge/revert/fixup
- Update pre-commit CI messages to conventional format
- Improve documentation with validation examples
This commit is contained in:
Alexander Minges 2025-07-17 11:21:29 +02:00
parent f3a1cf62fc
commit 9fc67c4674
Signed by: Athemis
SSH key fingerprint: SHA256:TUXshgulbwL+FRYvBNo54pCsI0auROsSEgSvueKbkZ4
3 changed files with 27 additions and 19 deletions

View file

@ -1,15 +1,20 @@
# Gitlint configuration file # Gitlint configuration file
# See https://jorisroovers.github.io/gitlint/configuration/ for documentation # See https://jorisroovers.github.io/gitlint/configuration/ for documentation
# This configuration enforces conventional commit message format # This configuration enforces conventional commit message format aligned with commitlint standards
[general] [general]
# Ignore specific rules if needed # Ignore specific rules - body is optional in conventional commits
ignore=body-changed-file-mention,body-match-regex,body-is-missing ignore=body-changed-file-mention,body-match-regex,body-is-missing
# Enable search regex style to avoid warnings # Enable search regex style to avoid warnings
regex-style-search=true regex-style-search=true
# Ignore merge commits and other automated commits
ignore-merge-commits=true
ignore-revert-commits=true
ignore-fixup-commits=true
ignore-squash-commits=true
[title-max-length] [title-max-length]
# Maximum title length # Maximum title length (50 is best practice for readability)
line-length=50 line-length=50
[title-must-not-contain-word] [title-must-not-contain-word]
@ -18,26 +23,25 @@ words=WIP,TODO,FIXME
[title-match-regex] [title-match-regex]
# Title must match conventional commit format # Title must match conventional commit format
regex=^(feat|fix|docs|style|refactor|test|chore|ci|build|perf|revert)(\(.+\))?: .+ # Supports optional scope and enforces lowercase types
regex=^(feat|fix|docs|style|refactor|test|chore|ci|build|perf|revert)(\([a-z0-9-]+\))?: [a-z].+
[body-max-line-length] [body-max-line-length]
# Maximum line length in the body # Maximum line length in the body (commitlint standard)
line-length=72 line-length=72
[body-min-length] [body-min-length]
# Minimum body length (0 = no minimum) # Minimum body length (0 = no minimum, body is optional)
min-length=0 min-length=0
# Body is optional - disabled via ignore list above
[ignore-by-title] [ignore-by-title]
# Ignore specific commit titles # Ignore specific commit titles (aligned with commitlint defaults)
regex=(Merge|Revert|Initial commit) regex=(Merge|Revert|Initial commit|Bump|Release|Version)
[ignore-by-body] [ignore-by-body]
# Ignore specific commit bodies # Ignore specific commit bodies
regex=(Signed-off-by|Co-authored-by) regex=(Signed-off-by|Co-authored-by)
[ignore-by-author-name] [ignore-by-author-name]
# Ignore commits by specific authors # Ignore commits by specific authors (bots and automated tools)
regex=(dependabot|renovate) regex=(dependabot|renovate|github-actions|pre-commit)

View file

@ -15,7 +15,7 @@ repos:
- id: check-json - id: check-json
- id: check-toml - id: check-toml
- id: mixed-line-ending - id: mixed-line-ending
args: ['--fix=lf'] args: ["--fix=lf"]
# Python code formatting and linting # Python code formatting and linting
- repo: https://github.com/astral-sh/ruff-pre-commit - repo: https://github.com/astral-sh/ruff-pre-commit
@ -43,12 +43,12 @@ repos:
# Configuration for specific hooks # Configuration for specific hooks
ci: ci:
autofix_commit_msg: | autofix_commit_msg: |
[pre-commit.ci] auto fixes from pre-commit hooks chore(deps): auto fixes from pre-commit hooks
for more information, see https://pre-commit.ci for more information, see https://pre-commit.ci
autofix_prs: true autofix_prs: true
autoupdate_branch: '' autoupdate_branch: ""
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate' autoupdate_commit_msg: "chore(deps): pre-commit autoupdate"
autoupdate_schedule: weekly autoupdate_schedule: weekly
skip: [] skip: []
submodules: false submodules: false

View file

@ -1,7 +1,7 @@
Git Commit Message Linting Git Commit Message Linting
=========================== ===========================
This project uses `gitlint <https://jorisroovers.github.io/gitlint/>`_ to enforce consistent commit message formatting. All commit messages must follow the `Conventional Commits <https://www.conventionalcommits.org/>`_ specification to ensure clear and standardized project history. This project uses `gitlint <https://jorisroovers.github.io/gitlint/>`_ to enforce consistent commit message formatting. All commit messages must follow the `Conventional Commits <https://www.conventionalcommits.org/>`_ specification to ensure clear and standardized project history. The configuration is harmonized with commitlint standards for maximum compatibility.
Why Commit Message Standards Matter Why Commit Message Standards Matter
----------------------------------- -----------------------------------
@ -126,10 +126,11 @@ Configuration
The project uses a ``.gitlint`` configuration file that enforces: The project uses a ``.gitlint`` configuration file that enforces:
* Maximum title length of 50 characters * Maximum title length of 50 characters
* Conventional commit format validation * Conventional commit format validation with lowercase descriptions
* Maximum body line length of 72 characters * Maximum body line length of 72 characters
* Exclusion of certain words like "WIP", "TODO", "FIXME" in titles * Exclusion of certain words like "WIP", "TODO", "FIXME" in titles
* Automatic ignoring of merge commits and dependency updates * Automatic ignoring of merge commits, reverts, fixups, and automated commits
* Scope validation with lowercase alphanumeric characters and hyphens
Linting Tools Linting Tools
------------- -------------
@ -220,6 +221,9 @@ Common Validation Errors
**Capitalized description** **Capitalized description**
Don't capitalize the first letter of the description: ``feat: add feature`` not ``feat: Add feature`` Don't capitalize the first letter of the description: ``feat: add feature`` not ``feat: Add feature``
**Invalid scope format**
Use only lowercase letters, numbers, and hyphens in scopes: ``feat(api-v2): add feature`` not ``feat(API_V2): add feature``
**Trailing period** **Trailing period**
Don't add a period at the end of the title: ``feat: add feature`` not ``feat: add feature.`` Don't add a period at the end of the title: ``feat: add feature`` not ``feat: add feature.``