Created
November 7, 2024 08:39
-
-
Save robertocaldas/ecc68b2e482cb5cfb8942f3aca2fb49e to your computer and use it in GitHub Desktop.
Add file to /.git/hooks
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 | |
# Get the list of files to be committed | |
files=$(git diff --cached --name-only) | |
# Check each diff for the word 'static' | |
for file in $files; do | |
if git diff --cached "$file" | grep -q 'static'; then | |
echo "Error: The word 'static' was found in file: $file" | |
exit 1 | |
fi | |
done | |
# If no files contained the word 'static', allow the commit | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment