A set of tools to validate git Conventional Commit messages.
Project description
Commit Message Git Hook
A set of tools to validate git Conventional Commit messages.
See the Conventional Commits Specification.
Installation Instructions
Install from PyPI (Python Package Index)
Run the script below to install the latest version of this package:
pip install commit-msg-git-hook --upgrade
Setup the Local Git Hook commit-msg
Run the script below to scaffold the hook:
python3 -m commit_msg_git_hook.setup
It does the following steps:
- Create a directory for git-hooks, by default
./.github/git-hooks
. - Set the hooks path to the current repository as the created directory.
- Create the
commit-msg
hook file if it doesn't exist.- Fill it with a basic script to call
commit_msg.main()
, from this package. - If the operating system is Linux, make the hook file executable.
- Fill it with a basic script to call
- Create a configuration file
commit-msg.config.json
if it doesn't exist.
Configuration Instructions
Customize the configuration file commit-msg.config.json
to fit your project's needs.
Probably you will want to add scopes, to fully utilize the Conventional Commits Specification.
Basic Usage
After setting up and adding the new files to your git remote repository, your collaborators will
need to run the installation and setup steps again.
But, this time, the setup will only set the hooks path and make sure the file commit-msg
is
executable.
Every time you make a commit, the hook will check if its message is in accordance to the specification and the project's customization.
How To Edit Commits
If your branch is not shared yet (not merged into develop
, for example), you can edit your commits
with the command below. Git will list the last n
commits and ask you whether you want to keep or
edit each one of them.
git rebase -i HEAD~n
More information here: https://docs.github.com/pt/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/changing-a-commit-message
Credits
This package was created from a Craicoverflow tutorial.
See the tutorial at the link: https://dev.to/craicoverflow/enforcing-conventional-commits-using-git-hooks-1o5p
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 Distribution
Built Distribution
Hashes for commit_msg_git_hook-0.3.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b940631cf4884051187ada3fe10ec6d152447f86be867512f8ba00aa0729a166 |
|
MD5 | 421b998a346140d545535a1243206504 |
|
BLAKE2b-256 | 4716c6860713dd29ffa23071c98cbc3a6fa959f00f9f69e98ac7c9b188455b06 |
Hashes for commit_msg_git_hook-0.3.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31fa9b37d05b177cf64cfeeac7bfece5b268bbd81de76e758f809bfeb217094c |
|
MD5 | bd3901558c6563b49da571a663bad7f4 |
|
BLAKE2b-256 | d7d38a0be86d207de4a16b93935be03cb2775d055001ab15f389ca756c422898 |