Skip to content

Instantly share code, notes, and snippets.

@marcocesarato
Created September 20, 2019 08:18
Show Gist options
  • Save marcocesarato/88d5e930851fbf203a1a268762f5e3de to your computer and use it in GitHub Desktop.
Save marcocesarato/88d5e930851fbf203a1a268762f5e3de to your computer and use it in GitHub Desktop.
Pre push git hooks for php-cs-fixer
#!/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