Skip to content

Instantly share code, notes, and snippets.

@brikou
Created March 7, 2013 14:26
Show Gist options
  • Save brikou/5108392 to your computer and use it in GitHub Desktop.
Save brikou/5108392 to your computer and use it in GitHub Desktop.
pre commit hook with php-cs-fixer
#!/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