Last active
October 22, 2017 13:12
-
-
Save bymyslf/caf7128327ed9fb4109887c32d61638e to your computer and use it in GitHub Desktop.
Git pre-receive hook to check GitVersion (http://gitversion.readthedocs.io/en/latest/) tags in merge message
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/bash | |
| # | |
| # check commit messages for semantic versioning tags | |
| REGEX="\\+semver:\\s?(breaking|major|feature|minor|fix|patch|none|skip)" | |
| DEFAULT_BRANCH=$(git symbolic-ref HEAD) | |
| ERROR_MSG="[POLICY] The commit message doesn't contains a semantic versioning tag" | |
| while read OLDREV NEWREV REFNAME ; do | |
| if [[ "${REFNAME}" != "${DEFAULT_BRANCH:=refs/heads/master}" ]]; then | |
| exit 0 | |
| else | |
| COMMIT_MESSAGE=`git log --format=%B -n 1 $NEWREV | cat -` | |
| if ! echo $COMMIT_MESSAGE | grep -iqE "$REGEX"; then | |
| echo "$ERROR_MSG: $COMMIT_MESSAGE" >&2 | |
| exit 1 | |
| fi | |
| fi | |
| done | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment