Skip to content

Instantly share code, notes, and snippets.

@marcocesarato
Last active September 20, 2019 08:18
Show Gist options
  • Save marcocesarato/8636f4d5e46f9b6a86300994e0d09de0 to your computer and use it in GitHub Desktop.
Save marcocesarato/8636f4d5e46f9b6a86300994e0d09de0 to your computer and use it in GitHub Desktop.
Pre commit and post merge git hooks for php-cs-fixer
#!/usr/bin/env bash
echo "Pre commit/Post merge 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 --verbose;
git add $CHANGED_FILES;
fi
echo "Pre commit/Post merge php-cs-fixer Finished"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment