Pre commit hook

Testing php code linting
This commit is contained in:
Dennis Eichhorn 2016-01-30 22:58:57 +01:00
parent 3a231cdd42
commit 3d72f7a0de
2 changed files with 14 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
**/

13
pre_commit.sh Normal file
View File

@ -0,0 +1,13 @@
#!/bin/bash
git diff --cached --name-only | while read FILE; do
if [[ "$FILE" =~ ^.+(php)$ ]]; then
if [[ -f ${FILE} ]]; then
php -l "$FILE" 1> /dev/null
if [ $? -ne 0 ]; then
echo -e "\e[1;31m\tAborting commit due to files with syntax errors.\e[0m" >&2
exit 1
fi
fi
fi
done || exit $?