Skip to content

Instantly share code, notes, and snippets.

@quangdaon
Created September 3, 2021 16:18
Show Gist options
  • Save quangdaon/e1ee18120b43f41aec14326e5dd6a998 to your computer and use it in GitHub Desktop.
Save quangdaon/e1ee18120b43f41aec14326e5dd6a998 to your computer and use it in GitHub Desktop.
Precommit Flag Guard
#!/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
@quangdaon
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment