Created
September 20, 2019 08:18
-
-
Save marcocesarato/88d5e930851fbf203a1a268762f5e3de to your computer and use it in GitHub Desktop.
Pre push git hooks for php-cs-fixer
This file contains 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 | |
echo "Pre push php-cs-fixer Start" | |
PHP_CS_FIXER="sh vendor/bin/php-cs-fixer" | |
PHP_CS_CONFIG=".cs.php" | |
CHANGED_FILES=$(git diff --cached --name-only --diff-filter=ACM -- '*.php') | |
if [ -n "$CHANGED_FILES" ]; then | |
$PHP_CS_FIXER fix --config "$PHP_CS_CONFIG" $CHANGED_FILES --dry-run --format=txt --verbose --diff --diff-format=udiff; | |
git add $CHANGED_FILES; | |
fi | |
echo "Pre push php-cs-fixer Finished" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment