cd <your-git-repo>
curl https://gist.githubusercontent.com/abhay-work/9fa2895f081f208990bcc2e0aabf59d2/raw/1bb266b327742efc27eb2fb736b8befa1f2aa645/commit-msg.sh > .git/hooks/commit-msg
rm .git/hooks/commit-msg.sample
chmod +x .git/hooks/commit-msg-
-
Save abhay-work/9fa2895f081f208990bcc2e0aabf59d2 to your computer and use it in GitHub Desktop.
Git commit-msg hook to validate for Jira issue (FS-XXX) at the beginning of every commit
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
| #!/usr/bin/env bash | |
| current_branch="$(git rev-parse --abbrev-ref HEAD)" | |
| # regex to validate in commit msg | |
| commit_regex='(^FS-[0-9]+)' | |
| error_msg="Aborting commit. Your commit message is missing a JIRA Issue ('FS-XXX') at the beginning." | |
| if ! grep -iqE "$commit_regex" "$1"; then | |
| echo "$error_msg" >&2 | |
| exit 1 | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment