Created
October 7, 2021 01:07
-
-
Save KyMidd/d948c6b3b6050ade3170f64e890e69a0 to your computer and use it in GitHub Desktop.
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
| # Check every commit message since ancestor for regex match | |
| for commit in $BRANCH_COMMITS; do | |
| if git log --max-count=1 --format=%B $commit | tr '[a-z]' '[A-Z]' | grep -iqE "$msg_regex"; then | |
| : #If commit matches regex, commit is valid, do nothing | |
| else | |
| # If commit doesn't match regex, commit isn't valid, print commit info | |
| echo "************" | |
| printf "Invalid commit message: \"%s\" and hash: %s\n" "$(git log --max-count=1 --format=%B $commit)" "$commit" | |
| echo "************" | |
| # Set this variable to trigger rejection if any commit fails regex | |
| invalidCommit=true | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment