Просмотр исходного кода

new config option which can be used more than once to exclude file paths from stats.

Alan Hamlett 10 лет назад
Родитель
Сommit
a41cdb4c3a
1 измененных файлов: 12 добавлений и 1 удалений
  1. 12
    1
      gitstats

+ 12
- 1
gitstats Просмотреть файл

@@ -47,7 +47,8 @@ conf = {
47 47
     'linear_linestats': 1,
48 48
     'project_name': '',
49 49
     'processes': 8,
50
-    'start_date': ''
50
+    'start_date': '',
51
+    'exclude_paths': [],
51 52
 }
52 53
 
53 54
 def getpipeoutput(cmds, quiet = False):
@@ -490,6 +491,14 @@ class GitDataCollector(DataCollector):
490 491
             size = int(parts[3])
491 492
             fullpath = parts[4]
492 493
 
494
+            exclude = False
495
+            for path in conf['exclude_paths']:
496
+                if path in fullpath:
497
+                    exclude = True
498
+                    break
499
+            if exclude:
500
+                continue
501
+
493 502
             self.total_size += size
494 503
             self.total_files += 1
495 504
 
@@ -1424,6 +1433,8 @@ class GitStats:
1424 1433
                     raise KeyError('no such key "%s" in config' % key)
1425 1434
                 if isinstance(conf[key], int):
1426 1435
                     conf[key] = int(value)
1436
+                elif isinstance(conf[key], list):
1437
+                    conf[key].append(value)
1427 1438
                 else:
1428 1439
                     conf[key] = value
1429 1440
             elif o in ('-h', '--help'):