Skip to content

Instantly share code, notes, and snippets.

@smoya
Last active May 17, 2016 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smoya/ae32f48d923c5d1f071bb778dae7dea0 to your computer and use it in GitHub Desktop.
Save smoya/ae32f48d923c5d1f071bb778dae7dea0 to your computer and use it in GitHub Desktop.
Tiny script to run a php cs-fix over a range of commits
#!/bin/bash
RANGE_COMMITS_FROM_HEAD=$1
SCRIPT=$2
if [ -z "$RANGE_COMMITS_FROM_HEAD" ]
then
RANGE_COMMITS_FROM_HEAD=1
fi
COMMITRANGE="HEAD~$RANGE_COMMITS_FROM_HEAD..HEAD"
if [ -z "$SCRIPT" ]
then
SCRIPT="./bin/php-cs-fixer fix"
fi
git diff-tree --no-commit-id --name-only -r $COMMITRANGE '*.php' | xargs -L1 --no-run-if-empty $SCRIPT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment