Skip to content

Instantly share code, notes, and snippets.

@jsnfwlr
Created April 20, 2018 05:12
Show Gist options
  • Save jsnfwlr/d8cd030446a999adda6d74d4f3cd8a83 to your computer and use it in GitHub Desktop.
Save jsnfwlr/d8cd030446a999adda6d74d4f3cd8a83 to your computer and use it in GitHub Desktop.
#!/bin/bash
commit_regex='^\[(GM\w-[0-9]+|HotFix\-[0-9]{4}\/[0-9]{2}\/[0-9]{2})\]\s\w*\s-\s'
error_msg="Aborting commit. Your commit message is incomplete.\r\nPlease include the following:\r\n\t - a JIRA Issue number or a HotFix-date\r\n\t - a component label\r\n\t - a summary of what was changed"
if [[ $(cat "$1" | grep -icE "$commit_regex") -eq 0 ]]; then
echo $(cat "$1" | grep -icE "$commit_regex")
printf "$error_msg" >&2
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment