Skip to content

Instantly share code, notes, and snippets.

@lxhunter
Last active January 3, 2017 17:27
Show Gist options
  • Save lxhunter/fe5384d28da3d0ed2efba33c61051779 to your computer and use it in GitHub Desktop.
Save lxhunter/fe5384d28da3d0ed2efba33c61051779 to your computer and use it in GitHub Desktop.
Git commit-msg hook to validate for semver
#!/usr/bin/env bash
# cd /to/where/the/repo/is/
# wget -O .git/hooks/commit-msg https://gist.githubusercontent.com/lxhunter/fe5384d28da3d0ed2efba33c61051779/raw/commit-msg.sh
# rm .git/hooks/commit-msg.sample
# chmod +x .git/hooks/commit-msg
message=$(cat $1)
if ! [[ "$message" =~ ^\[(patch|minor|major)\] ]]; then
echo "Commit aborted! Your commit message is missing semantic versioning [patch|minor|major]" >&2
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment