Skip to content

Commit fc92236

Browse files
committed
Merge pull request #8 from devdrops/fix-file-pattern
Merged #8.
2 parents 84f9f09 + 3cfbdea commit fc92236

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

config.dist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,6 @@ PHPMD_SUFFIXES=php
3434

3535
# PHP Mess Detector list of files/folders to exclude
3636
PHPMD_EXCLUDE=
37+
38+
# List of file patterns to exclude (using `grep`)
39+
GIT_EXCLUDE="Test"

pre-commit

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,15 @@ fi
4444

4545
# This is the magic:
4646
# Retrieve all files in staging area that are added, modified or renamed
47-
# but no deletions etc
48-
FILES=$(git diff-index --name-only --cached --diff-filter=ACMR $against -- )
47+
# but no deletions etc.
48+
# Lets first check if there are any file pattern to exclude from this list
49+
if [ "$GIT_EXCLUDE" != "" ]; then
50+
GIT_EXCLUDE_LIST="| grep -v $GIT_EXCLUDE"
51+
else
52+
GIT_EXCLUDE_LIST=""
53+
fi
54+
55+
FILES=$(git diff-index --name-only --cached --diff-filter=ACMR $against -- $GIT_EXCLUDE_LIST)
4956

5057
if [ "$FILES" == "" ]; then
5158
exit 0

0 commit comments

Comments
 (0)