Skip to content

Commit 19d7c4a

Browse files
committed
Fixes and improvements.
1 parent 8135d3b commit 19d7c4a

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

config.dist

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Enable tools
2+
PHPCS_ACTIVE=1
3+
PHPMD_ACTIVE=1
4+
15
# Path to binaries.
26
PHPCS_BIN=/usr/local/bin/phpcs
37
PHPMD_BIN=/usr/local/bin/phpmd
@@ -36,4 +40,4 @@ PHPMD_SUFFIXES=php
3640
PHPMD_EXCLUDE=
3741

3842
# List of file patterns to exclude (using `grep`)
39-
GIT_EXCLUDE="Test"
43+
GIT_EXCLUDE=

pre-commit

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
23
##########
34
# Git Pre-Commit file for PHP projects
45
###
@@ -13,6 +14,7 @@
1314
#
1415
##########
1516

17+
1618
##########
1719
# DEFAULT SETTINGS
1820
###
@@ -71,12 +73,14 @@ else
7173
GIT_EXCLUDE_LIST=""
7274
fi
7375

76+
7477
FILES=$(git diff-index --name-only --cached --diff-filter=ACMR $against -- $GIT_EXCLUDE_LIST)
7578

7679
if [ "$FILES" == "" ]; then
7780
exit 0
7881
fi
7982

83+
8084
# Create temporary copy of staging area
8185
if [ -e $TMP_STAGING ]; then
8286
rm -rf $TMP_STAGING
@@ -114,7 +118,7 @@ else
114118
fi
115119

116120
if [ "$PHPCS_CODING_STANDARD" != "" ]; then
117-
PHPCS_CODING_STANDARD="--sniffs=$PHPCS_CODING_STANDARD"
121+
PHPCS_CODING_STANDARD="--standard=$PHPCS_CODING_STANDARD"
118122
else
119123
PHPCS_CODING_STANDARD=""
120124
fi
@@ -169,6 +173,7 @@ else
169173
PHPMD_EXCLUDE_LIST=""
170174
fi
171175

176+
172177
##########
173178
# Copy contents of staged version of files to temporary staging area
174179
# because we only want the staged version that will be commited and not
@@ -194,22 +199,22 @@ done
194199
if [ "$PHPCS_ACTIVE" == "1" ]; then
195200
echo ""
196201
tput setaf 7; echo " :: PHP CodeSniffer inspection :: "
197-
PHPCS_OUTPUT=$($PHPCS_BIN -s $IGNORE_WARNINGS --standard=$PHPCS_CODING_STANDARD $ENCODING $IGNORE $STAGED_FILES)
202+
PHPCS_OUTPUT=$($PHPCS_BIN -s $IGNORE_WARNINGS $PHPCS_CODING_STANDARD $ENCODING $IGNORE $STAGED_FILES)
198203
PHPCS_RETVAL=$?
199204

200205
if [ $PHPCS_RETVAL -ne 0 ]; then
201-
tput setaf 1; echo " -> Issues found: "
206+
tput setaf 1; echo " \u2718 Issues found: "
202207
tput setaf 7; echo "$PHPCS_OUTPUT"
203208

204209
rm -rf $TMP_STAGING
205210

206211
exit $PHPCS_RETVAL
207212
else
208-
tput setaf 2; echo " -> Inspection is OK!"
213+
tput setaf 2; echo " \u2714 Inspection is OK!"
209214
fi
210215
else
211216
echo ""
212-
tput setaf 8; echo ":-( PHP CodeSniffer inspection is OFF."
217+
tput setaf 8; echo " :-( PHP CodeSniffer inspection is OFF."
213218
fi
214219

215220

@@ -223,25 +228,27 @@ if [ "$PHPMD_ACTIVE" == "1" ]; then
223228
PHPMD_RETVAL=$?
224229

225230
if [ $PHPMD_RETVAL -ne 0 ]; then
226-
tput setaf 1; echo " -> Issues found: "
231+
tput setaf 1; echo " \u2718 Issues found: "
227232
tput setaf 7; echo "$PHPMD_OUTPUT"
228233

229234
rm -rf $TMP_STAGING
230235

231236
exit $PHPMD_RETVAL
232237
else
233-
tput setaf 2; echo " -> Inspection is OK!"
238+
tput setaf 2; echo " '\u2714' Inspection is OK!"
234239
fi
235240
else
236241
echo ""
237-
tput setaf 8; echo ":-( PHP Mess Detector inspection is OFF."
242+
tput setaf 8; echo " :-( PHP Mess Detector inspection is OFF."
238243
fi
239244

240245
tput setaf 7;
241246

242247

248+
243249
rm -rf $TMP_STAGING
244250

245251

252+
246253
echo ""
247254
exit 0;

0 commit comments

Comments
 (0)