From 7dc2a38d41ae76b6b60e4f41125fcea7a28515b8 Mon Sep 17 00:00:00 2001 From: Martin Eckhardt Date: Mon, 5 Mar 2012 13:58:45 +0100 Subject: [PATCH] Moved PHPCS_IGNORE to $FILES_TO_CHECK loop. The ignore pattern is applied in the files to check loop, since it was not possible to ignore a file that was already in the files to check array. For instance, I want all *.php files to be checked, except files with *.ini.append.php extension. --- phpcs-pre-commit/pre-commit | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/phpcs-pre-commit/pre-commit b/phpcs-pre-commit/pre-commit index 78d36ca..24b9d59 100755 --- a/phpcs-pre-commit/pre-commit +++ b/phpcs-pre-commit/pre-commit @@ -53,7 +53,11 @@ for FILE in $FILES do echo "$FILE" | egrep -q "$PHPCS_FILE_PATTERN" RETVAL=$? - if [ "$RETVAL" -eq "0" ] + echo "$FILE" | egrep -q "$PHPCS_IGNORE" + RETVAL_IGNORE=$? + # File is found in file pattern and not found in ignore pattern. + # Then add it to files to check. + if [ "$RETVAL" -eq "0" ] && [ "$RETVAL_IGNORE" -eq "1" ] then FILES_TO_CHECK="$FILES_TO_CHECK $FILE" fi @@ -63,13 +67,6 @@ if [ "$FILES_TO_CHECK" == "" ]; then exit 0 fi -# execute the code sniffer -if [ "$PHPCS_IGNORE" != "" ]; then - IGNORE="--ignore=$PHPCS_IGNORE" -else - IGNORE="" -fi - # Copy contents of staged version of files to temporary staging area # because we only want the staged version that will be commited and not # the version in the working directory @@ -85,7 +82,7 @@ do STAGED_FILES="$STAGED_FILES $TMP_STAGING/$FILE" done -OUTPUT=$($PHPCS_BIN -s --standard=$PHPCS_CODING_STANDARD $IGNORE $STAGED_FILES) +OUTPUT=$($PHPCS_BIN -s --standard=$PHPCS_CODING_STANDARD $STAGED_FILES) RETVAL=$? # delete temporary copy of staging area