Skip to content

Instantly share code, notes, and snippets.

@jc1987
Last active December 21, 2016 16:32
Show Gist options
  • Save jc1987/a92f2be3d95da91d26ea7f2cb017a183 to your computer and use it in GitHub Desktop.
Save jc1987/a92f2be3d95da91d26ea7f2cb017a183 to your computer and use it in GitHub Desktop.
precommit cs
#!/usr/bin/env bash
echo "pre commit hook start phpcs"
CURRENT_DIRECTORY=`pwd`
GIT_HOOKS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PROJECT_DIRECTORY="$GIT_HOOKS_DIR/../.."
cd $PROJECT_DIRECTORY;
PHP_CS_FIXER="php php-cs-fixer.phar"
git status -s | cut -c4- | grep -e '\(.*\).php$' |while read line; do
${PHP_CS_FIXER} fix --dry-run --diff --level=symfony --verbose ${line};
done
cd $CURRENT_DIRECTORY;
echo "pre commit hook finish phpcs"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment