Skip to content

Instantly share code, notes, and snippets.

@Dessyk
Dessyk / commit-msg
Created October 11, 2018 20:28 — forked from dogriffiths/commit-msg
Git hook to check that commit messages are in Semantic format.
#!/bin/sh
#
# Git hook to check for semantic commit messages in the form mentioned here
#
# https://seesparkbox.com/foundry/semantic_commit_messages
export TYPE=$(cut -d ':' -f1 < "$1" | xargs)
export VERB=$(cut -d ':' -f2 | cut -d ' ' -f2 < "$1")
(echo "$TYPE" | egrep '^(feat|chore|docs|fix|refactor|style|test)$' > /dev/null) || (echo "Missing type feat|chore|docs|fix|refactor|style|test"; exit 1)
(grep "$VERB" .git/hooks/verbs.txt > /dev/null) || (echo "Missing a verb"; exit 1)