build: add PHPCompat checks to pre-commit hook
This commit is contained in:
parent
9926a42e8c
commit
de4e53f941
1 changed files with 24 additions and 21 deletions
|
@ -29,33 +29,36 @@ do
|
||||||
FILES="$FILES $PROJECT/$FILE"
|
FILES="$FILES $PROJECT/$FILE"
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -f "$PROJECT/phpcs.ruleset.xml" ]
|
#if [ -f "$PROJECT/phpcs.ruleset.xml" ]
|
||||||
then
|
#then
|
||||||
RULESET="$PROJECT/phpcs.ruleset.xml"
|
# RULESET="$PROJECT/phpcs.ruleset.xml"
|
||||||
elif [ -f "$PROJECT/phpcs.xml.dist" ]
|
#elif [ -f "$PROJECT/phpcs.xml.dist" ]
|
||||||
then
|
#then
|
||||||
RULESET="$PROJECT/phpcs.xml.dist"
|
# RULESET="$PROJECT/phpcs.xml.dist"
|
||||||
else
|
#else
|
||||||
RULESET="WordPress"
|
RULESETS=["WordPress","PHPCompatibilityWP"]
|
||||||
fi
|
#fi
|
||||||
|
|
||||||
if [ "$FILES" != "" ]
|
if [ "$FILES" != "" ]
|
||||||
then
|
then
|
||||||
|
for RULESET in $RULESETS; do
|
||||||
echo "Checking Code Standard Compliance, using $RULESET as ruleset standard..."
|
echo "Checking Code Standard Compliance, using $RULESET as ruleset standard..."
|
||||||
./vendor/bin/phpcs --standard="$RULESET" --colors --encoding=utf-8 -n -p $FILES
|
./vendor/bin/phpcs --standard="$RULESET" --runtime-set testVersion 7.0- --colors --encoding=utf-8 -n -p $FILES
|
||||||
if [ $? != 0 ]
|
if [ $? != 0 ]
|
||||||
then
|
then
|
||||||
echo "Coding standards errors have been detected. Running phpcbf..."
|
echo "Coding standards errors have been detected. Running phpcbf..."
|
||||||
./vendor/bin/phpcbf --standard="$RULESET" --encoding=utf-8 -n -p $FILES
|
./vendor/bin/phpcbf --standard="$RULESET" --runtime-set testVersion 7.0- --encoding=utf-8 -n -p $FILES
|
||||||
git add $FILES
|
git add $FILES
|
||||||
echo "Running Code Sniffer again..."
|
echo "Running Code Sniffer again..."
|
||||||
./vendor/bin/phpcs --standard="$RULESET" --colors --encoding=utf-8 -n -p $FILES
|
./vendor/bin/phpcs --standard="$RULESET" --runtime-set testVersion 7.0- --colors --encoding=utf-8 -n -p $FILES
|
||||||
if [ $? != 0 ]
|
if [ $? != 0 ]
|
||||||
then
|
then
|
||||||
echo "Errors found not fixable automatically. You need to manually fix them."
|
echo "Errors found not fixable automatically. You need to manually fix them."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
echo "$RULESET passed."
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit $?
|
exit $?
|
||||||
|
|
Reference in a new issue