Skip to content

Commit c9d60d4

Browse files
author
Marc Paffen
committed
Git Template: phpcs pre-commit
1 parent 985ad0f commit c9d60d4

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
3+
# stolen from template file
4+
if git rev-parse --verify HEAD
5+
then
6+
against=HEAD
7+
else
8+
# Initial commit: diff against an empty tree object
9+
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
10+
fi
11+
12+
FILES=`git diff --cached --name-only --diff-filter=ACMR $against | grep \\\\.php`
13+
14+
if [ "$FILES" != "" ]
15+
then
16+
echo "Running Code Sniffer..."
17+
phpcs -n -p $FILES
18+
if [ $? != 0 ]
19+
then
20+
echo "Fix the error before commit."
21+
exit 1
22+
fi
23+
fi
24+
25+
exit $?

0 commit comments

Comments
 (0)