Last active
September 20, 2019 08:18
-
-
Save marcocesarato/8636f4d5e46f9b6a86300994e0d09de0 to your computer and use it in GitHub Desktop.
Pre commit and post merge 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 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