Skip to main content

Check commit message formatting, branch naming, commit author, email, and more.

Project description

PyPI CI Quality Gate Status CodeCov commit-check SLSA

Overview

Commit Check is a free, powerful tool that enforces commit metadata standards, including commit message, branch naming, committer name/email, and commit signoff. Fully customizable with error messages and suggested commands, it ensures compliance across teams.

As an alternative to GitHub Enterprise Metadata restrictions and Bitbucket’s paid puglin Yet Another Commit Checker, Commit Check stands out by integrating DevOps principles and Infrastructure as Code (IaC).

Configuration

Use Default Configuration

Use Custom Configuration

Create a config file .commit-check.yml under your repository’s root directory, e.g., .commit-check.yml

Usage

Running as GitHub Action

Please see commit-check/commit-check-action

Running as pre-commit hook

-   repo: https://github.com/commit-check/commit-check
    rev: the tag or revision
    hooks: # support hooks
    -   id: check-message  # it requires hook prepare-commit-msg
    -   id: check-branch
    -   id: check-author-name
    -   id: check-author-email
    -   id: check-commit-signoff
    -   id: check-merge-base

Running as CLI

Global Installation

sudo pip3 install -U commit-check

User Installation

pip install -U commit-check

Install from Git Repo

pip install git+https://github.com/commit-check/commit-check.git@main

Then, run commit-check from the command line. For more information, see the docs.

Running as Git Hooks

To configure the hook, create a script file in the .git/hooks/ directory.

#!/bin/sh
commit-check --message --branch --author-name --author-email --commit-signoff --merge-base

Save the script file as pre-push and make it executable:

chmod +x .git/hooks/pre-push

Now, git push will trigger this hook automatically.

Example

Check Commit Message Failed

Commit rejected by Commit-Check.

  (c).-.(c)    (c).-.(c)    (c).-.(c)    (c).-.(c)    (c).-.(c)
   / ._. \      / ._. \      / ._. \      / ._. \      / ._. \
 __\( C )/__  __\( H )/__  __\( E )/__  __\( C )/__  __\( K )/__
(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)
   || E ||      || R ||      || R ||      || O ||      || R ||
 _.' '-' '._  _.' '-' '._  _.' '-' '._  _.' '-' '._  _.' '-' '._
(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)
 `-´     `-´  `-´     `-´  `-´     `-´  `-´     `-´  `-´     `-´

Type message check failed => my test commit message
It doesn't match regex: ^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\([\w\-\.]+\))?(!)?: ([\w ])+([\s\S]*)

The commit message should be structured as follows:

<type>[optional scope]: <description>
[optional body]
[optional footer(s)]

More details please refer to https://www.conventionalcommits.org
Suggest: please check your commit message whether matches above regex

Check Branch Naming Failed

Commit rejected by Commit-Check.

  (c).-.(c)    (c).-.(c)    (c).-.(c)    (c).-.(c)    (c).-.(c)
   / ._. \      / ._. \      / ._. \      / ._. \      / ._. \
 __\( C )/__  __\( H )/__  __\( E )/__  __\( C )/__  __\( K )/__
(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)
   || E ||      || R ||      || R ||      || O ||      || R ||
 _.' '-' '._  _.' '-' '._  _.' '-' '._  _.' '-' '._  _.' '-' '._
(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)
 `-´     `-´  `-´     `-´  `-´     `-´  `-´     `-´  `-´     `-´

Commit rejected.

Type branch check failed => my-test-branch
It doesn't match regex: ^(bugfix|feature|release|hotfix|task|chore)\/.+|(master)|(main)|(HEAD)|(PR-.+)

Branches must begin with these types: bugfix/ feature/ release/ hotfix/ task/ chore/
Suggest: run command `git checkout -b type/branch_name`

Badging your repository

You can add a badge to your repository to show that you use commit-check!

commit-check

Markdown

[![commit-check](https://img.shields.io/badge/commit--check-enabled-brightgreen?logo=Git&logoColor=white)](https://github.com/commit-check/commit-check)

reStructuredText

.. image:: https://img.shields.io/badge/commit--check-enabled-brightgreen?logo=Git&logoColor=white
    :target: https://github.com/commit-check/commit-check
    :alt: commit-check

Versioning

Versioning follows Semantic Versioning.

Have question or feedback?

Please post to issues for feedback, feature requests, or bug reports.

License

This project is released under the MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

commit_check-0.9.2-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file commit_check-0.9.2-py3-none-any.whl.

File metadata

  • Download URL: commit_check-0.9.2-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for commit_check-0.9.2-py3-none-any.whl
Algorithm Hash digest
SHA256 66f71c966139a9fe043fce8c74f73807060f8fc32e72dd093eec1a157e03168d
MD5 7081900f408e10a66e893d3db2a10b1b
BLAKE2b-256 527a5d22f8c47b88ea77773848758d9bfa14e3469a0f1119754fd5bd6df4513c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page