Pārlūkot izejas kodu

use exclude_paths as regular expression

Alan Hamlett 10 gadus atpakaļ
vecāks
revīzija
651b8218a4
1 mainītis faili ar 7 papildinājumiem un 2 dzēšanām
  1. 7
    2
      gitstats

+ 7
- 2
gitstats Parādīt failu

@@ -477,6 +477,10 @@ class GitDataCollector(DataCollector):
477 477
             except ValueError:
478 478
                 print 'Warning: failed to parse line "%s"' % line
479 479
 
480
+
481
+        # compile exclude_paths regex
482
+        conf['exclude_paths'] = [re.compile(pattern, re.IGNORECASE) for pattern in conf['exclude_paths']]
483
+
480 484
         # extensions and size of files
481 485
         lines = getpipeoutput(['git ls-tree -r -l -z %s' % getcommitrange('HEAD', end_only = True)]).split('\000')
482 486
         blobs_to_read = []
@@ -492,11 +496,12 @@ class GitDataCollector(DataCollector):
492 496
             fullpath = parts[4]
493 497
 
494 498
             exclude = False
495
-            for path in conf['exclude_paths']:
496
-                if path in fullpath:
499
+            for pattern in conf['exclude_paths']:
500
+                if pattern.search(fullpath):
497 501
                     exclude = True
498 502
                     break
499 503
             if exclude:
504
+                print 'Excluding file: %s' % fullpath
500 505
                 continue
501 506
 
502 507
             self.total_size += size