Skip to main content

A tool to check git commit messages format

Project description

commit-format

A tool to check your commit messages format.

Supported checkers

Primarily disigned for to check for spelling mistakes in commit messages, commit-format now comes with various checker allowing to:

  • Check that each message lines does not exceed a length limit.
  • Check for spelling mistake on commit messages.
  • NEW Check commit header/body/footer against a defined template.

Installation

$ pip install commit-format

Help command will show you all availables options:

$ commit-format --help

Format options

-l (--limit INT) Line limit check

You can check that every line in the commit message (including the title/header) does not exceed a length limit. By default the value is set to 72.

A limit of '0' --limit 0 will disable the line limit checker.

Usage:

$ commit-format -l 80

-ns (--no-spelling) Disable spelling mistake

By default, commit-format checks for common spelling mistakes in the commit messages.
This option rely on codespell and may produce some false-positive results.
This new option -ns --no-spelling let the user disable the spelling checker.

$ commit-format -ns

-t (--template FILE) Template compliance

You can provide a configuration TOML file template to validate the commit header/footer format and required symbols.

Usage:

$ commit-format -t /path/to/.commit-format

Template schema (TOML):

  • [header]
    • pattern: Regex that the first line (header) must match.
  • [body]
    • allow_empty: true/false to allow a commit with only a header (no body).
    • blank_line_after_header: true/false to enforce a blank line between header and body.
  • [footer]
    • required: true/false to require a footer section.
    • pattern: Regex that each footer line must match.

Example .commit-format:

[header]
# header line regex:
pattern = ^(feat: |fic: |ci: |doc: ).+$

[body]
# Allow empty body commit message. (i.e. single line commit message).
allow_empty = false
# Require that header line and body line are separated by an empty line.
blank_line_after_header = true

[footer]
# Require a footer line
required = true
# Footer line regex
pattern = ^(Signed-off-by: ).+$

Behavior option

-a (--all) Force checking all commits

By default the script will only run on a branch and stop when reaching the base branch.
If run on a base branch directly, the script will throw an error:

$ commit-format
Running on branch main. Abort checking commits.

This measure is there to prevent running the script over past commits.

If running on 'main'/'master' is required, option -a will force the script to run regadless the branch name.

Usage:

$ commit-format -a

-b (--base) Base branch name

You can set the base branch name according to your project.
As described in option -a section the base branch name is required to let the script restrict it's analysis on the commits of a branch.
Default value for the base branch name is main.

When running this script in a CI environment, you may be required to fetch your base branch manually. See github workflow example.

Usage:

$ commit-format -b origin/main

-v (--verbosity)

Display debug messages from the script.

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

commit_format-0.2.1.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

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

commit_format-0.2.1-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file commit_format-0.2.1.tar.gz.

File metadata

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

File hashes

Hashes for commit_format-0.2.1.tar.gz
Algorithm Hash digest
SHA256 2d0a1e01dbe1784e4492b5d79edbd5c3ed5341d54fe61d15a9042ad102f9c12e
MD5 3c31b175bdf4a288475f07da1b099c7b
BLAKE2b-256 6003e3bd98c15657b80a48397608d61087ebee8b0932a2ecce1e86a0ccbf08eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for commit_format-0.2.1.tar.gz:

Publisher: release.yml on AlexFabre/commit-format

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

File details

Details for the file commit_format-0.2.1-py3-none-any.whl.

File metadata

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

File hashes

Hashes for commit_format-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0669a51c7b49623ea0f2b6ae5551ba7b35bd524975faa27ecccbe533231baaef
MD5 f391658d675d0ff21648a131be03ef26
BLAKE2b-256 dc0b11b0f6e78e4b787fdf0d1b036a5f56345fe7e67b70061de27196b23e0620

See more details on using hashes here.

Provenance

The following attestation bundles were made for commit_format-0.2.1-py3-none-any.whl:

Publisher: release.yml on AlexFabre/commit-format

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