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>
This commit is contained in:
parent
3f0bcc6871
commit
f1ab9e8373
7
gitstats
7
gitstats
@ -475,10 +475,11 @@ class GitDataCollector(DataCollector):
|
|||||||
# Similar to the above, but never use --first-parent
|
# Similar to the above, but never use --first-parent
|
||||||
# (we need to walk through every commit to know who
|
# (we need to walk through every commit to know who
|
||||||
# committed what, not just through mainline)
|
# committed what, not just through mainline)
|
||||||
lines = getpipeoutput(['git log --shortstat --pretty=format:"%%at %%aN" %s' % (getcommitrange('HEAD'))]).split('\n')
|
lines = getpipeoutput(['git log --shortstat --date-order --pretty=format:"%%at %%aN" %s' % (getcommitrange('HEAD'))]).split('\n')
|
||||||
lines.reverse()
|
lines.reverse()
|
||||||
files = 0; inserted = 0; deleted = 0
|
files = 0; inserted = 0; deleted = 0
|
||||||
author = None
|
author = None
|
||||||
|
stamp = 0
|
||||||
for line in lines:
|
for line in lines:
|
||||||
if len(line) == 0:
|
if len(line) == 0:
|
||||||
continue
|
continue
|
||||||
@ -488,7 +489,11 @@ class GitDataCollector(DataCollector):
|
|||||||
pos = line.find(' ')
|
pos = line.find(' ')
|
||||||
if pos != -1:
|
if pos != -1:
|
||||||
try:
|
try:
|
||||||
|
oldstamp = stamp
|
||||||
(stamp, author) = (int(line[:pos]), line[pos+1:])
|
(stamp, author) = (int(line[:pos]), line[pos+1:])
|
||||||
|
if oldstamp > stamp:
|
||||||
|
# clock skew, keep old timestamp to avoid having ugly graph
|
||||||
|
stamp = oldstamp
|
||||||
if author not in self.authors:
|
if author not in self.authors:
|
||||||
self.authors[author] = { 'lines_added' : 0, 'lines_removed' : 0, 'commits' : 0}
|
self.authors[author] = { 'lines_added' : 0, 'lines_removed' : 0, 'commits' : 0}
|
||||||
self.authors[author]['commits'] = self.authors[author].get('commits', 0) + 1
|
self.authors[author]['commits'] = self.authors[author].get('commits', 0) + 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user