-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
38 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/sh | ||
|
||
pass=true | ||
|
||
files=$(git diff --cached --name-only --diff-filter=ACMR | grep -E '\.(php|phtml)$') | ||
if [ "$files" != "" ]; then | ||
|
||
# Run php syntax check before commit | ||
for file in ${files}; do | ||
php -l ${file} | ||
if [ $? -ne 0 ]; then | ||
pass=false | ||
fi | ||
done | ||
|
||
# Run php-cs-fixer validation before commit | ||
echo "$files" | xargs php ./vendor/bin/php-cs-fixer fix --diff --config .php-cs-fixer.dist.php | ||
if [ $? -ne 0 ]; then | ||
pass=false | ||
fi | ||
|
||
# Automatically add files that may have been fixed by php-cs-fixer | ||
echo "$files" | xargs git add | ||
fi | ||
|
||
if $pass; then | ||
exit 0 | ||
else | ||
echo "" | ||
echo "PRE-COMMIT HOOK FAILED:" | ||
echo "Code style validation failed. Please fix errors and try committing again." | ||
exit 1 | ||
fi |
This file contains 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
This file contains 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
This file contains 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
This file contains 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