Skip to content

Instantly share code, notes, and snippets.

Created December 11, 2016 20:23
What would you like to do?
#!/usr/bin/env bash
# set this to your active development branch
current_branch="$(git rev-parse --abbrev-ref HEAD)"
# only check commit messages on main development branch
[ "$current_branch" != "$develop_branch" ] && exit 0
# regex to validate in commit msg
error_msg="Aborting commit. Please follow appropriate commit message format:
<type>(<scope>): <message>
fix(response): check data type before performing arithmatic
or Merge pull request from #234
Allowed types:
feat: A new feature
fix: A bug fix
doc: Documentation only changes
style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
refactor: A code change that neither fixes a bug or adds a feature
perf: A code change that improves performance
test: Adding missing tests
chore: Changes to the build process or auxiliary tools and libraries such as documentation generation
Commits starting with 'Merged' are passed through
if ! grep -iqE "$commit_regex" "$1"; then
echo "$error_msg" >&2
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment