11#! /bin/bash
2+
23# #########
34# Git Pre-Commit file for PHP projects
45# ##
1314#
1415# #########
1516
17+
1618# #########
1719# DEFAULT SETTINGS
1820# ##
7173 GIT_EXCLUDE_LIST=" "
7274fi
7375
76+
7477FILES=$( git diff-index --name-only --cached --diff-filter=ACMR $against -- $GIT_EXCLUDE_LIST )
7578
7679if [ " $FILES " == " " ]; then
7780 exit 0
7881fi
7982
83+
8084# Create temporary copy of staging area
8185if [ -e $TMP_STAGING ]; then
8286 rm -rf $TMP_STAGING
114118fi
115119
116120if [ " $PHPCS_CODING_STANDARD " != " " ]; then
117- PHPCS_CODING_STANDARD=" --sniffs =$PHPCS_CODING_STANDARD "
121+ PHPCS_CODING_STANDARD=" --standard =$PHPCS_CODING_STANDARD "
118122else
119123 PHPCS_CODING_STANDARD=" "
120124fi
169173 PHPMD_EXCLUDE_LIST=" "
170174fi
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
194199if [ " $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
210215else
211216 echo " "
212- tput setaf 8; echo " :-( PHP CodeSniffer inspection is OFF."
217+ tput setaf 8; echo " :-( PHP CodeSniffer inspection is OFF."
213218fi
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
235240else
236241 echo " "
237- tput setaf 8; echo " :-( PHP Mess Detector inspection is OFF."
242+ tput setaf 8; echo " :-( PHP Mess Detector inspection is OFF."
238243fi
239244
240245tput setaf 7;
241246
242247
248+
243249rm -rf $TMP_STAGING
244250
245251
252+
246253echo " "
247254exit 0;
0 commit comments