@@ -47,7 +47,9 @@ conf = {
47
47
'linear_linestats' : 1 ,
48
48
'project_name' : '' ,
49
49
'processes' : 8 ,
50
- 'start_date' : ''
50
+ 'start_date' : '' ,
51
+ 'excluded_authors' : [],
52
+ 'excluded_prefixes' : []
51
53
}
52
54
53
55
def getpipeoutput (cmds , quiet = False ):
@@ -322,6 +324,8 @@ class GitDataCollector(DataCollector):
322
324
parts = re .split ('\s+' , line , 2 )
323
325
commits = int (parts [1 ])
324
326
author = parts [2 ]
327
+ if author in conf ["excluded_authors" ]:
328
+ continue
325
329
self .tags [tag ]['commits' ] += commits
326
330
self .tags [tag ]['authors' ][author ] = commits
327
331
@@ -338,6 +342,8 @@ class GitDataCollector(DataCollector):
338
342
timezone = parts [3 ]
339
343
author , mail = parts [4 ].split ('<' , 1 )
340
344
author = author .rstrip ()
345
+ if author in conf ["excluded_authors" ]:
346
+ continue
341
347
mail = mail .rstrip ('>' )
342
348
domain = '?'
343
349
if mail .find ('@' ) != - 1 :
@@ -434,14 +440,16 @@ class GitDataCollector(DataCollector):
434
440
self .commits_by_timezone [timezone ] = self .commits_by_timezone .get (timezone , 0 ) + 1
435
441
436
442
# outputs "<stamp> <files>" for each revision
437
- revlines = getpipeoutput (['git rev-list --pretty=format:"%%at %%T" %s' % getlogrange ('HEAD' ), 'grep -v ^commit' ]).strip ().split ('\n ' )
443
+ revlines = getpipeoutput (['git rev-list --pretty=format:"%%at %%T %%an " %s' % getlogrange ('HEAD' ), 'grep -v ^commit' ]).strip ().split ('\n ' )
438
444
lines = []
439
445
revs_to_read = []
440
446
time_rev_count = []
441
447
#Look up rev in cache and take info from cache if found
442
448
#If not append rev to list of rev to read from repo
443
449
for revline in revlines :
444
- time , rev = revline .split (' ' )
450
+ time , rev , author = revline .split (' ' )
451
+ if author in conf ["excluded_authors" ]:
452
+ continue
445
453
#if cache empty then add time and rev to list of new rev's
446
454
#otherwise try to read needed info from cache
447
455
if 'files_in_tree' not in self .cache .keys ():
@@ -489,6 +497,14 @@ class GitDataCollector(DataCollector):
489
497
blob_id = parts [2 ]
490
498
size = int (parts [3 ])
491
499
fullpath = parts [4 ]
500
+ exclude = False
501
+ for path in conf ["excluded_prefixes" ]:
502
+ if fullpath .startswith (path ):
503
+ exclude = True
504
+ break
505
+
506
+ if exclude :
507
+ continue
492
508
493
509
self .total_size += size
494
510
self .total_files += 1
@@ -540,6 +556,7 @@ class GitDataCollector(DataCollector):
540
556
lines .reverse ()
541
557
files = 0 ; inserted = 0 ; deleted = 0 ; total_lines = 0
542
558
author = None
559
+ last_line = ""
543
560
for line in lines :
544
561
if len (line ) == 0 :
545
562
continue
@@ -550,35 +567,36 @@ class GitDataCollector(DataCollector):
550
567
if pos != - 1 :
551
568
try :
552
569
(stamp , author ) = (int (line [:pos ]), line [pos + 1 :])
553
- self .changes_by_date [stamp ] = { 'files' : files , 'ins' : inserted , 'del' : deleted , 'lines' : total_lines }
554
-
555
- date = datetime .datetime .fromtimestamp (stamp )
556
- yymm = date .strftime ('%Y-%m' )
557
- self .lines_added_by_month [yymm ] = self .lines_added_by_month .get (yymm , 0 ) + inserted
558
- self .lines_removed_by_month [yymm ] = self .lines_removed_by_month .get (yymm , 0 ) + deleted
559
-
560
- yy = date .year
561
- self .lines_added_by_year [yy ] = self .lines_added_by_year .get (yy ,0 ) + inserted
562
- self .lines_removed_by_year [yy ] = self .lines_removed_by_year .get (yy , 0 ) + deleted
563
-
564
- files , inserted , deleted = 0 , 0 , 0
570
+ if author not in conf ["excluded_authors" ]:
571
+ self .changes_by_date [stamp ] = { 'files' : files , 'ins' : inserted , 'del' : deleted , 'lines' : total_lines }
572
+
573
+ date = datetime .datetime .fromtimestamp (stamp )
574
+ yymm = date .strftime ('%Y-%m' )
575
+ self .lines_added_by_month [yymm ] = self .lines_added_by_month .get (yymm , 0 ) + inserted
576
+ self .lines_removed_by_month [yymm ] = self .lines_removed_by_month .get (yymm , 0 ) + deleted
577
+
578
+ yy = date .year
579
+ self .lines_added_by_year [yy ] = self .lines_added_by_year .get (yy ,0 ) + inserted
580
+ self .lines_removed_by_year [yy ] = self .lines_removed_by_year .get (yy , 0 ) + deleted
581
+
582
+ files , inserted , deleted = 0 , 0 , 0
583
+
584
+ numbers = getstatsummarycounts (last_line )
585
+ if len (numbers ) == 3 :
586
+ (files , inserted , deleted ) = map (lambda el : int (el ), numbers )
587
+ total_lines += inserted
588
+ total_lines -= deleted
589
+ self .total_lines_added += inserted
590
+ self .total_lines_removed += deleted
591
+ else :
592
+ print 'Warning: failed to handle line "%s"' % line
593
+ (files , inserted , deleted ) = (0 , 0 , 0 )
565
594
except ValueError :
566
595
print 'Warning: unexpected line "%s"' % line
567
596
else :
568
597
print 'Warning: unexpected line "%s"' % line
569
598
else :
570
- numbers = getstatsummarycounts (line )
571
-
572
- if len (numbers ) == 3 :
573
- (files , inserted , deleted ) = map (lambda el : int (el ), numbers )
574
- total_lines += inserted
575
- total_lines -= deleted
576
- self .total_lines_added += inserted
577
- self .total_lines_removed += deleted
578
-
579
- else :
580
- print 'Warning: failed to handle line "%s"' % line
581
- (files , inserted , deleted ) = (0 , 0 , 0 )
599
+ last_line = line
582
600
#self.changes_by_date[stamp] = { 'files': files, 'ins': inserted, 'del': deleted }
583
601
self .total_lines += total_lines
584
602
@@ -606,21 +624,22 @@ class GitDataCollector(DataCollector):
606
624
try :
607
625
oldstamp = stamp
608
626
(stamp , author ) = (int (line [:pos ]), line [pos + 1 :])
609
- if oldstamp > stamp :
610
- # clock skew, keep old timestamp to avoid having ugly graph
611
- stamp = oldstamp
612
- if author not in self .authors :
613
- self .authors [author ] = { 'lines_added' : 0 , 'lines_removed' : 0 , 'commits' : 0 }
614
- self .authors [author ]['commits' ] = self .authors [author ].get ('commits' , 0 ) + 1
615
- self .authors [author ]['lines_added' ] = self .authors [author ].get ('lines_added' , 0 ) + inserted
616
- self .authors [author ]['lines_removed' ] = self .authors [author ].get ('lines_removed' , 0 ) + deleted
617
- if stamp not in self .changes_by_date_by_author :
618
- self .changes_by_date_by_author [stamp ] = {}
619
- if author not in self .changes_by_date_by_author [stamp ]:
620
- self .changes_by_date_by_author [stamp ][author ] = {}
621
- self .changes_by_date_by_author [stamp ][author ]['lines_added' ] = self .authors [author ]['lines_added' ]
622
- self .changes_by_date_by_author [stamp ][author ]['commits' ] = self .authors [author ]['commits' ]
623
- files , inserted , deleted = 0 , 0 , 0
627
+ if author not in conf ["excluded_authors" ]:
628
+ if oldstamp > stamp :
629
+ # clock skew, keep old timestamp to avoid having ugly graph
630
+ stamp = oldstamp
631
+ if author not in self .authors :
632
+ self .authors [author ] = { 'lines_added' : 0 , 'lines_removed' : 0 , 'commits' : 0 }
633
+ self .authors [author ]['commits' ] = self .authors [author ].get ('commits' , 0 ) + 1
634
+ self .authors [author ]['lines_added' ] = self .authors [author ].get ('lines_added' , 0 ) + inserted
635
+ self .authors [author ]['lines_removed' ] = self .authors [author ].get ('lines_removed' , 0 ) + deleted
636
+ if stamp not in self .changes_by_date_by_author :
637
+ self .changes_by_date_by_author [stamp ] = {}
638
+ if author not in self .changes_by_date_by_author [stamp ]:
639
+ self .changes_by_date_by_author [stamp ][author ] = {}
640
+ self .changes_by_date_by_author [stamp ][author ]['lines_added' ] = self .authors [author ]['lines_added' ]
641
+ self .changes_by_date_by_author [stamp ][author ]['commits' ] = self .authors [author ]['commits' ]
642
+ files , inserted , deleted = 0 , 0 , 0
624
643
except ValueError :
625
644
print 'Warning: unexpected line "%s"' % line
626
645
else :
@@ -644,6 +663,8 @@ class GitDataCollector(DataCollector):
644
663
645
664
for name in self .authors .keys ():
646
665
a = self .authors [name ]
666
+ #if a is None:
667
+ # continue
647
668
a ['commits_frac' ] = (100 * float (a ['commits' ])) / self .getTotalCommits ()
648
669
date_first = datetime .datetime .fromtimestamp (a ['first_commit_stamp' ])
649
670
date_last = datetime .datetime .fromtimestamp (a ['last_commit_stamp' ])
@@ -1489,3 +1510,5 @@ if __name__=='__main__':
1489
1510
g = GitStats ()
1490
1511
g .run (sys .argv [1 :])
1491
1512
1513
+
1514
+ mon @open - freelancer :~ / dev / go / src / openfreelancers $
0 commit comments