Bladeren bron

Don't create ugly graphs on clock skew

We collect and accumulate data based on the order of the output of "git
log", which is not necessarily ordered by timestamp. Adding --date-order
should improve the situation, but isn't sufficient at least on git.git's
repository.

In addition, when encountering a date that is prior to the last one
encountered, we change it to be the last encountered date. A better
solution would be to actually order the lines before starting to count.

Signed-off-by: Heikki Hokkanen <hoxu@users.sf.net>
Matthieu Moy 15 jaren geleden
bovenliggende
commit
f1ab9e8373
1 gewijzigde bestanden met toevoegingen van 6 en 1 verwijderingen
  1. 6
    1
      gitstats

+ 6
- 1
gitstats Bestand weergeven

@@ -475,10 +475,11 @@ class GitDataCollector(DataCollector):
475 475
 		# Similar to the above, but never use --first-parent
476 476
 		# (we need to walk through every commit to know who
477 477
 		# committed what, not just through mainline)
478
-		lines = getpipeoutput(['git log --shortstat --pretty=format:"%%at %%aN" %s' % (getcommitrange('HEAD'))]).split('\n')
478
+		lines = getpipeoutput(['git log --shortstat --date-order --pretty=format:"%%at %%aN" %s' % (getcommitrange('HEAD'))]).split('\n')
479 479
 		lines.reverse()
480 480
 		files = 0; inserted = 0; deleted = 0
481 481
 		author = None
482
+		stamp = 0
482 483
 		for line in lines:
483 484
 			if len(line) == 0:
484 485
 				continue
@@ -488,7 +489,11 @@ class GitDataCollector(DataCollector):
488 489
 				pos = line.find(' ')
489 490
 				if pos != -1:
490 491
 					try:
492
+						oldstamp = stamp
491 493
 						(stamp, author) = (int(line[:pos]), line[pos+1:])
494
+						if oldstamp > stamp:
495
+							# clock skew, keep old timestamp to avoid having ugly graph
496
+							stamp = oldstamp
492 497
 						if author not in self.authors:
493 498
 							self.authors[author] = { 'lines_added' : 0, 'lines_removed' : 0, 'commits' : 0}
494 499
 						self.authors[author]['commits'] = self.authors[author].get('commits', 0) + 1