diff --git a/config.dist b/config.dist index 4f713e8..92b4836 100644 --- a/config.dist +++ b/config.dist @@ -34,3 +34,6 @@ PHPMD_SUFFIXES=php # PHP Mess Detector list of files/folders to exclude PHPMD_EXCLUDE= + +# List of file patterns to exclude (using `grep`) +GIT_EXCLUDE="Test" diff --git a/pre-commit b/pre-commit index b6c3006..4339ef6 100644 --- a/pre-commit +++ b/pre-commit @@ -44,8 +44,15 @@ fi # This is the magic: # Retrieve all files in staging area that are added, modified or renamed -# but no deletions etc -FILES=$(git diff-index --name-only --cached --diff-filter=ACMR $against -- ) +# but no deletions etc. +# Lets first check if there are any file pattern to exclude from this list +if [ "$GIT_EXCLUDE" != "" ]; then + GIT_EXCLUDE_LIST="| grep -v $GIT_EXCLUDE" +else + GIT_EXCLUDE_LIST="" +fi + +FILES=$(git diff-index --name-only --cached --diff-filter=ACMR $against -- $GIT_EXCLUDE_LIST) if [ "$FILES" == "" ]; then exit 0