Created
September 3, 2021 16:18
-
-
Save quangdaon/e1ee18120b43f41aec14326e5dd6a998 to your computer and use it in GitHub Desktop.
Precommit Flag Guard
This file contains 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 | |
your_name="Q" | |
dont_push_flag="QSTOP" | |
matched_files=`git grep --name-only "$dont_push_flag" $(git diff --cached --name-only)` | |
if [ -n "$matched_files" ] | |
then | |
echo "$your_name, what are you doing?! A $dont_push_flag flag was found in your commit." | |
printf "$matched_files" | |
exit 1 | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Based off https://gist.github.com/erikcox/5d6d78941ef3faddab9f