Created
June 28, 2020 20:00
-
-
Save Frizi/1cb774149789c194590454b09f6d053c to your computer and use it in GitHub Desktop.
Git pre-commit hook to prevent checking in "nocheckin" or other specified strings.
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
#!/bin/sh | |
exec git show ":$1" |
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
#!/bin/bash | |
declare -a arr=("nocheckin" "dbg!") | |
for i in "${arr[@]}" | |
do | |
git diff --cached --name-only | xargs rg --with-filename --pre ".git/hooks/git-show-staged.sh" -n "$i" && echo "COMMIT REJECTED! Found '$i' references. Please remove them before commiting." && exit 1 | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment