Created
October 12, 2018 14:32
-
-
Save particledecay/020278d8091f28a24ecca2b6436dc48a to your computer and use it in GitHub Desktop.
Git hook for enforcing Conform commit message policies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh [0/68765] | |
| # | |
| # A hook script to check for conventional commit message format. | |
| # only run if a config exists | |
| if [ ! -f ./.conform.yaml ] | |
| then | |
| echo "No .conform.yaml file found. Ignoring conform." | |
| exit 0 | |
| fi | |
| # there's a config, but no command | |
| if [ -z "$(which conform)" ] | |
| then | |
| echo "'conform' executable not found. Install it and make sure it is in your PATH." | |
| echo "You can install it with 'go get -u github.com/autonomy/conform'." | |
| exit 1 | |
| fi | |
| # there's a command, but it doesn't support the commit-msg hook | |
| if [ -z "$(conform enforce -h | awk '$1 == "--commit-msg-file"')" ] | |
| then | |
| echo "Installed version of conform does not support commit-msg hooks. Please update." | |
| exit 1 | |
| fi | |
| conform enforce --commit-msg-file $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment