Skip to content

Instantly share code, notes, and snippets.

@edwint88
Last active November 14, 2017 14:31
Show Gist options
  • Save edwint88/6100e61be9d230f58ce1c2feb5c820c7 to your computer and use it in GitHub Desktop.
Save edwint88/6100e61be9d230f58ce1c2feb5c820c7 to your computer and use it in GitHub Desktop.
Using PHP CS Fixer on CI with Mercurial
#!/bin/bash
CHANGED_FILES=$(hg status -m -a -n | grep "**.php$" | grep -v "vendor");
printf "Files to be checked:\n\n";
echo "$CHANGED_FILES";
printf "\n"
if [[ -n "$CHANGED_FILES" ]]
then
EXTRA_ARGS=('--' ${CHANGED_FILES[@]});
printf "=============>>> START execute php-cs-fixer <<<=============\n\n";
RESULT=$(vendor-ci/bin/php-cs-fixer fix --config=.php_cs.dist -v --dry-run --stop-on-violation --using-cache=no "${EXTRA_ARGS[@]}");
echo "$RESULT";
printf "=============>>> FINISH execute php-cs-fixer <<<=============\n\n";
if [[ $RESULT == *"1)"* ]]; then
printf "=============>>> Files are NOT well FORMATTED! <<<=============\n\n";
exit 1;
fi
else
echo "NO Files were changed!";
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment