From 3cfbdead492ccf3a4bf530e6d977d4ad050ed35b Mon Sep 17 00:00:00 2001 From: Davi Marcondes Moreira Date: Thu, 14 Apr 2016 20:10:33 -0300 Subject: [PATCH] Added a new variable to exclude files using grep, from the git diff list. --- config.dist | 3 +++ pre-commit | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) 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