Skip to content

Instantly share code, notes, and snippets.

@Zayon
Created October 25, 2017 14:19
Show Gist options
  • Save Zayon/07c2beba7f0dcefb2e46d036a77df8db to your computer and use it in GitHub Desktop.
Save Zayon/07c2beba7f0dcefb2e46d036a77df8db to your computer and use it in GitHub Desktop.
pre-commit php-cs-fixer
#!/usr/bin/env bash
ROOT=$(git rev-parse --show-toplevel)
cd "$ROOT"
git --git-dir "$ROOT"/.git --work-tree "$ROOT" status --porcelain | grep -e '^[AM]\(.*\).php$' | cut -c 3- | while read line; do
bin/php-cs-fixer fix --dry-run --diff --no-ansi --verbose "$line"
if [ $? -ne 0 ]; then
exit 1
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment