Last active
February 21, 2020 09:44
-
-
Save bkonetzny/cb4aeec57f9207d8f9162269b8342abc to your computer and use it in GitHub Desktop.
Check a list of changed files, e.g. run through php-cs-fixer
This file contains hidden or 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
#!/bin/bash | |
BRANCH=master | |
git diff --name-status ${BRANCH} | \ | |
while read -r status srcfile destfile | |
do | |
if [ -z "$destfile" ] | |
then | |
# Use source file (e.g. modified) | |
changedfile=$srcfile | |
else | |
# Use destination file (e.g. moved) | |
changedfile=$destfile | |
fi | |
# Skip deleted or non-PHP files | |
if [[ $status != 'D' && $changedfile == *".php" ]]; then | |
echo "Fixing file ${changedfile}" | |
php-cs-fixer fix "${changedfile}" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment