Skip to content

Collection of customizable Git hooks to enforce quality of commit messages.

Notifications You must be signed in to change notification settings

an23rd/git-hooks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Git Hooks

This repository contains a collection of Git hooks designed to enforce commit message standards and improve the quality of commit messages. The hooks are implemented in shell scripts and are intended to be used in a Git repository to automatically validate commit messages before they are accepted.

Available Formats

Below are the available commit message formats that this repository supports:

Format Description File name of the Git hook
50/72 Commit Message Format Enforces the well-known 50/72 commit message formatting standard. commit-msg-basic-format
Conventional Commits Validates commit messages against the Conventional Commits specification. commit-msg-conventional-commits
Gitmoji Ensures commit messages follow the Gitmoji specification. commit-msg-gitmoji

Usage

To install a hook, copy the desired hook script from the hooks directory to your Git repository's .git/hooks directory and rename the file to commit-msg. For more information, see 8.3 Customizing Git - Git Hooks of the Pro Git book.

The Git hooks provided in this repository can be customized to fit your specific needs. The hook scripts contains variables and patterns that you can adjust to enforce different commit message standards.

For example, customize the allowed commit types and scope content by modifying the variables allowed_types and allowed_scope_regex of commit-msg-conventional-commits or commit-msg-gitmoji. Additionally, you can use the script scripts/parse_gitmojis.py to automatically update the emojis from the official Github repository.

Example

To validate the commit messages against the Conventional Commits specification, copy the file hooks/commit-msg-conventional-commits to .git/hooks/ of your Git repository and rename it to commit-msg.

To customize the hook, open .git/hooks/commit-msg and adjust the variables as needed. For example, to add a new commit type to the hook, locate the allowed_types array and add your new commit type to the array.

Limitations

Please note that the current implementation of the Conventional Commits hook does not analyze the footer section of the commit messages. This means that any additional information typically included in the footer, such as breaking changes or issue references, will not be validated by the hook.

About

Collection of customizable Git hooks to enforce quality of commit messages.

Topics

Resources

Stars

Watchers

Forks