Skip to content

Commit

Permalink
use exclude_paths as regular expression
Browse files Browse the repository at this point in the history
  • Loading branch information
alanhamlett committed Mar 26, 2015
1 parent d03967b commit a88dd27
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions gitstats
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,10 @@ class GitDataCollector(DataCollector):
except ValueError:
print 'Warning: failed to parse line "%s"' % line


# compile exclude_paths regex
conf['exclude_paths'] = [re.compile(pattern, re.IGNORECASE) for pattern in conf['exclude_paths']]

# extensions and size of files
lines = getpipeoutput(['git ls-tree -r -l -z %s' % getcommitrange('HEAD', end_only = True)]).split('\000')
blobs_to_read = []
Expand All @@ -492,11 +496,12 @@ class GitDataCollector(DataCollector):
fullpath = parts[4]

exclude = False
for path in conf['exclude_paths']:
if path in fullpath:
for pattern in conf['exclude_paths']:
if pattern.search(fullpath):
exclude = True
break
if exclude:
print 'Excluding file: %s' % fullpath
continue

self.total_size += size
Expand Down

0 comments on commit a88dd27

Please sign in to comment.