Created
November 20, 2018 21:18
-
-
Save AurelienLoyer/4e9d3bdcc54031baa807cfaa009eacb5 to your computer and use it in GitHub Desktop.
[Pre Commit Git Hook] Prevent special character in filenames #git
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 | |
for file in $(git diff --cached --name-only) | |
do | |
if [[ $file == *['!'@#éáàè\$%^\&*()+]* ]] | |
then | |
echo "pre-commit: Aborting commit due to filename with special character ($file)" | |
exit 1 | |
fi | |
done | |
echo "pre-commit: No special character found :)" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment