Created
March 7, 2013 14:26
-
-
Save brikou/5108392 to your computer and use it in GitHub Desktop.
pre commit hook with php-cs-fixer
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
#!/usr/bin/env bash | |
EXIT_CODE=0 | |
for FILE in `git status --porcelain | egrep '^[AM]' | egrep '\.(md|php|twig|xml|yml)$' | awk '{print $2;}'`; do | |
php-cs-fixer fix $FILE --verbose --dry-run | |
if [[ $? != 0 ]]; then | |
echo "f=$FILE; php-cs-fixer fix \$f --verbose && git add \$f" | |
EXIT_CODE=1 | |
fi | |
done | |
exit $EXIT_CODE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment