Skip to main content

Commit message linter and formatter

Project description

gitfluff

Commit message linter with presets, custom formats, and cleanup automation. Fully compliant with Conventional Commits 1.0.0. Skips linting while Git is creating a merge commit.

This Python package distributes prebuilt gitfluff binaries. On first use, the correct release binary for your platform is downloaded and cached under ~/.cache/gitfluff.

Quick Start

Install with uv:

uv tool install gitfluff

Run without installation (uvx):

uvx gitfluff --version

Lint a commit message:

gitfluff lint .git/COMMIT_EDITMSG

Auto-clean and rewrite:

gitfluff lint .git/COMMIT_EDITMSG --write

Optional: fail after rewrite (recommended for hooks)

Add a .gitfluff.toml to enable automatic cleanup and stop the commit if a rewrite happened:

preset = "conventional"
write = true

[rules]
exit_nonzero_on_rewrite = true

Hook Integrations

Native Git Hook

Install commit-msg hook:

gitfluff hook install commit-msg

With auto-cleanup:

gitfluff hook install commit-msg --write

pre-commit Framework

Add to .pre-commit-config.yaml:

default_install_hook_types:
  - pre-commit
  - commit-msg

repos:
  - repo: https://github.com/Goldziher/gitfluff
    rev: v0.8.0
    hooks:
      - id: gitfluff-lint
        stages: [commit-msg]
        # args: ["--write"]  # optional, or set `write = true` in .gitfluff.toml
        # args: ["--msg-pattern", "^JIRA-[0-9]+: .+"]  # optional regex override

Install the hooks:

pre-commit install

Lefthook (uvx)

Add to lefthook.yml:

commit-msg:
  commands:
    gitfluff:
      run: uvx gitfluff lint {1}

Install hooks:

npx lefthook install

Optional configuration

No configuration is required—the default Conventional Commits rules apply immediately. If you want project overrides, create .gitfluff.toml:

preset = "conventional-body"  # optional preset override
write = true

[rules]
no_emojis = true
title_suffix = "\\(JIRA-[0-9]+\\)"
exit_nonzero_on_rewrite = true

Any setting can be left out; omit the file entirely to keep defaults.

Advanced usage

  • Override rules per-invocation using CLI flags (e.g. --preset, --msg-pattern, --cleanup-pattern, --exclude, --cleanup, --single-line, --no-emojis, --ascii-only, --title-prefix, --title-suffix).
  • Set GITFLUFF_BINARY to point at a custom build when testing unpublished versions.
  • Clear the cache (rm ~/.cache/gitfluff/gitfluff*) to force a fresh download.

License

MIT © Na'aman Hirschfeld and contributors

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

gitfluff-0.8.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

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

gitfluff-0.8.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file gitfluff-0.8.0.tar.gz.

File metadata

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

File hashes

Hashes for gitfluff-0.8.0.tar.gz
Algorithm Hash digest
SHA256 eaecd3984d96f77f91f2c6b5cc1af7e965ba90e72f529679fce2a116bab5be7d
MD5 9f2049efcf49e93a9c79f7fbce470e36
BLAKE2b-256 17ff5a0699cbf4f2eff8ec9e415bd54c869143c19ce7a733081ac53f0cb1b33e

See more details on using hashes here.

Provenance

The following attestation bundles were made for gitfluff-0.8.0.tar.gz:

Publisher: publish.yaml on Goldziher/gitfluff

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

File details

Details for the file gitfluff-0.8.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for gitfluff-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c4b7dda09b94164f1330d9899fb2783a66adfe232ec51b762a950e9f1dda3b64
MD5 cbe71b7e54ba8ec2e7b8213217630c0e
BLAKE2b-256 4e39fe6d34c553b13fbfa97b57a3d7b4d4353b1d8d2ffd075a267f01d32c527e

See more details on using hashes here.

Provenance

The following attestation bundles were made for gitfluff-0.8.0-py3-none-any.whl:

Publisher: publish.yaml on Goldziher/gitfluff

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