Skip to content

Instantly share code, notes, and snippets.

@klees
Created February 22, 2021 10:19
Show Gist options
  • Save klees/e751df890d73b7b2bb7885b728d571a7 to your computer and use it in GitHub Desktop.
Save klees/e751df890d73b7b2bb7885b728d571a7 to your computer and use it in GitHub Desktop.
ILIAS Git Hooks
#!/bin/sh
if [ -x libs/composer/vendor/bin/php-cs-fixer ]; then
echo "PHP CS Fixer is installed begin to check PHP files"
CONFIGURATION_FILE="./CI/PHP-CS-Fixer/code-format.php_cs"
if [ -f $CONFIGURATION_FILE]; then
echo "The configuration file is not found under ${CONFIGURATION_FILE}"
fi
CHANGED_FILES=$(git diff --cached --name-only --diff-filter=ACM -- '*.php')
return_code=0
result=""
for FILE in $CHANGED_FILES
do
echo "Fix file: ${FILE}"
partial_result=$(libs/composer/vendor/bin/php-cs-fixer fix --using-cache=no --diff --config=$CONFIGURATION_FILE $FILE)
partial_return_code=$?
if [ $partial_return_code -ne 0 ]; then
return_code=$partial_return_code
exit 1
fi
git add $FILE
done
echo "End of fixing PHP files"
else
echo "Couldn't find 'libs/composer/vendor/bin/php-cs-fixer'. Make sure it is installed, for more information check the local '/docs/coding
-style.md'"
exit 1
fi
echo "Code Style is OK."
#!/bin/sh
composer install
./CI/PHPUnit/run_tests.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment