Skip to main content

validate commit messages and metadata

Project description

Validate Commits

Validate commit messages and metadata.

Usage

$ validate-commits --help
usage: validate-commits [-h] [--since SINCE]

options:
  -h, --help     show this help message and exit
  --since SINCE  check commits since this reference

The tool will check all commits between main and the current HEAD.

Checks

Built-in rules

There are several built-in rules, which are checked automatically:

  • "Commit author has no email" -- all commits must have an author email and all co-authors (in Co-authored-by trailers) must have an email.
  • "Commit is empty" -- empty commits are not allowed.
  • "Fixup commit" -- 'fixup' commits should be squashed into the commit they fix up.

Custom rules

Custom rules may be provided in a validate-commits-config.toml file. Rules must be provided as a regular expression pattern and an error message and will be checked against the designated target.

Commit summary

Checks for the commit summary (the first line of the commit message) may be defined in a [[checks.summary]] table, e.g:

[[checks.summary]]
pattern = '\d'
message = "Numbers in commit summary."

Author email

Checks for author and co-author email addresses may be defined in a [[checks.author_email]] table, e.g:

[[checks.author_email]]
pattern = '@example\.(com|net|org)$'
message = "Fake email address provided."

pre-commit

A pre-push hook is provided for pre-commit and can be configured in your .pre-commit-config.yaml:

default_install_hook_types: [pre-commit, pre-push]
default_stages: [pre-commit]

repos:
    # ...
    - repo: https://github.com/samueljsb/validate-commits
      rev: v0.0.3
      hooks:
          - id: validate-commits

N.B. This hook only runs in the pre-push stage. Therefore, the pre-push hook must be installed, which may require pre-commit install to be run again. To ensure other hooks are not run unexpectedly during the pre-push stage, the default stage must be set at the top level.

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

validate_commits-0.0.3.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

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

validate_commits-0.0.3-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file validate_commits-0.0.3.tar.gz.

File metadata

  • Download URL: validate_commits-0.0.3.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for validate_commits-0.0.3.tar.gz
Algorithm Hash digest
SHA256 919e5c2494c25c48e61f51d3570f34d45316884a62b3e5ddcceca34e8b3e301f
MD5 d68a9d770fbc880148ca30078036db84
BLAKE2b-256 f9dbf71ffc38b016f48387526c4ea4ad4a7b0a4b0007de39cf78f3d2fd92af8b

See more details on using hashes here.

Provenance

The following attestation bundles were made for validate_commits-0.0.3.tar.gz:

Publisher: build_and_publish.yaml on samueljsb/validate-commits

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

File details

Details for the file validate_commits-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for validate_commits-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 44801b699f3ea349682049a6bc80c506a3d51acecbdc4fe20ee27bb7afbdfbf1
MD5 964452f68f6c8f6999c29e8b0ed8e8e3
BLAKE2b-256 780d9ed1904ff08ab40c7ca228ce189a11ce1d62892de9f147a8467c3ad9aeb1

See more details on using hashes here.

Provenance

The following attestation bundles were made for validate_commits-0.0.3-py3-none-any.whl:

Publisher: build_and_publish.yaml on samueljsb/validate-commits

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