Check commit message formatting, branch naming, commit author, email, and more.
Project description
Overview
Check commit message formatting, branch naming, committer name, email, and more. Alternative to Yet Another Commit Checker.
requiring commit message to match regex
requiring branch naming to match regex
requiring committer name and email to match regex
customizing error message
customizing suggest command
Purpose
commit-check is a tool designed for teams.
Its main purpose is to standardize the format of commit message, branch naming, etc, and makes it possible to:
writing descriptive commit is easy to read
identify branch according to the branch type
triggering the specific types of commit/branch CI build
automatically generate changelogs
Configuration
Use custom configuration
Create a config file .commit-check.yml under your repository root directory, e.g. .commit-check.yml
Use default configuration
If you did’t set .commit-check.yml, commit-check will use the default configuration.
i.e. the commit message will follow the rules of conventional commits, branch naming follow bitbucket branching model.
Usage
There are a variety of ways you can use commit-check as follows.
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:
- id: check-message
- id: check-branch
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 you can run commit-check command line. More about commit-check --help please see docs.
Running as Git Hooks
To configure the hook, you need to create a new script file in the .git/hooks/ directory of your Git repository.
Here is an example script that you can use to set up the hook:
#!/bin/sh
commit-check --message --branch --author-name --author-email
Save the script file to pre-push and make it executable by running the following command:
chmod +x .git/hooks/pre-push
Then when you run git push command, this push hook will be run 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 ||
_.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._
(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)
`-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´
Invalid commit message => test
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 to run => git commit --amend --no-verify
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.
Invalid branch name => test
It doesn't match regex: ^(bugfix|feature|release|hotfix|task)\/.+|(master)|(main)|(HEAD)|(PR-.+)
Branches must begin with these types: bugfix/ feature/ release/ hotfix/ task/
Suggest to run => git checkout -b type/branch_name
Badging your repository
You can add a badge to your repository to show your contributors / users that you use 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?
To provide feedback (requesting a feature or reporting a bug) please post to issues.
License
This project is released under the MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file commit_check-0.5.2-py3-none-any.whl
.
File metadata
- Download URL: commit_check-0.5.2-py3-none-any.whl
- Upload date:
- Size: 10.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e341c3d7ecbee5589e6ba5e3ed0ed78038c19342a4860ca439a2d7389577afa7 |
|
MD5 | 9387ca3e0ce31c7775390002d22fa7d0 |
|
BLAKE2b-256 | de0131b51b387ad71a026eb2809b4a0e972d36fe3e338b85bc40ac03e3d82bb3 |