|
|
|
|
|
|
34
|
'style': 'gitstats.css',
|
34
|
'style': 'gitstats.css',
|
|
35
|
'max_authors': 20,
|
35
|
'max_authors': 20,
|
|
36
|
'authors_top': 5,
|
36
|
'authors_top': 5,
|
|
|
|
37
|
+ 'commit_begin': '',
|
|
|
|
38
|
+ 'commit_end': '',
|
|
37
|
}
|
39
|
}
|
|
38
|
|
40
|
|
|
39
|
def getpipeoutput(cmds, quiet = False):
|
41
|
def getpipeoutput(cmds, quiet = False):
|
|
|
|
|
|
|
56
|
exectime_external += (end - start)
|
58
|
exectime_external += (end - start)
|
|
57
|
return output.rstrip('\n')
|
59
|
return output.rstrip('\n')
|
|
58
|
|
60
|
|
|
|
|
61
|
+def getcommitrange(defaultrange = '', end_only = False):
|
|
|
|
62
|
+ if len(conf['commit_end']) > 0:
|
|
|
|
63
|
+ if end_only or len(conf['commit_begin']) == 0:
|
|
|
|
64
|
+ return conf['commit_end']
|
|
|
|
65
|
+ return '%s..%s' % (conf['commit_begin'], conf['commit_end'])
|
|
|
|
66
|
+ return defaultrange
|
|
|
|
67
|
+
|
|
59
|
def getkeyssortedbyvalues(dict):
|
68
|
def getkeyssortedbyvalues(dict):
|
|
60
|
return map(lambda el : el[1], sorted(map(lambda el : (el[1], el[0]), dict.items())))
|
69
|
return map(lambda el : el[1], sorted(map(lambda el : (el[1], el[0]), dict.items())))
|
|
61
|
|
70
|
|
|
|
|
|
|
|
67
|
def getversion():
|
76
|
def getversion():
|
|
68
|
global VERSION
|
77
|
global VERSION
|
|
69
|
if VERSION == 0:
|
78
|
if VERSION == 0:
|
|
70
|
- VERSION = getpipeoutput(["git rev-parse --short HEAD"]).split('\n')[0]
|
|
|
|
|
|
79
|
+ VERSION = getpipeoutput(["git rev-parse --short %s" % getcommitrange('HEAD')]).split('\n')[0]
|
|
71
|
return VERSION
|
80
|
return VERSION
|
|
72
|
|
81
|
|
|
73
|
class DataCollector:
|
82
|
class DataCollector:
|
|
|
|
|
|
|
161
|
DataCollector.collect(self, dir)
|
170
|
DataCollector.collect(self, dir)
|
|
162
|
|
171
|
|
|
163
|
try:
|
172
|
try:
|
|
164
|
- self.total_authors = int(getpipeoutput(['git shortlog -s', 'wc -l']))
|
|
|
|
|
|
173
|
+ self.total_authors = int(getpipeoutput(['git shortlog -s %s' % getcommitrange(), 'wc -l']))
|
|
165
|
except:
|
174
|
except:
|
|
166
|
self.total_authors = 0
|
175
|
self.total_authors = 0
|
|
167
|
#self.total_lines = int(getoutput('git-ls-files -z |xargs -0 cat |wc -l'))
|
176
|
#self.total_lines = int(getoutput('git-ls-files -z |xargs -0 cat |wc -l'))
|
|
|
|
|
|
|
237
|
|
246
|
|
|
238
|
# Collect revision statistics
|
247
|
# Collect revision statistics
|
|
239
|
# Outputs "<stamp> <date> <time> <timezone> <author> '<' <mail> '>'"
|
248
|
# Outputs "<stamp> <date> <time> <timezone> <author> '<' <mail> '>'"
|
|
240
|
- lines = getpipeoutput(['git rev-list --pretty=format:"%at %ai %an <%aE>" HEAD', 'grep -v ^commit']).split('\n')
|
|
|
|
|
|
249
|
+ lines = getpipeoutput(['git rev-list --pretty=format:"%%at %%ai %%an <%%aE>" %s' % getcommitrange('HEAD'), 'grep -v ^commit']).split('\n')
|
|
241
|
for line in lines:
|
250
|
for line in lines:
|
|
242
|
parts = line.split(' ', 4)
|
251
|
parts = line.split(' ', 4)
|
|
243
|
author = ''
|
252
|
author = ''
|
|
|
|
|
|
|
341
|
# TODO Optimize this, it's the worst bottleneck
|
350
|
# TODO Optimize this, it's the worst bottleneck
|
|
342
|
# outputs "<stamp> <files>" for each revision
|
351
|
# outputs "<stamp> <files>" for each revision
|
|
343
|
self.files_by_stamp = {} # stamp -> files
|
352
|
self.files_by_stamp = {} # stamp -> files
|
|
344
|
- revlines = getpipeoutput(['git rev-list --pretty=format:"%at %T" HEAD', 'grep -v ^commit']).strip().split('\n')
|
|
|
|
|
|
353
|
+ revlines = getpipeoutput(['git rev-list --pretty=format:"%%at %%T" %s' % getcommitrange('HEAD'), 'grep -v ^commit']).strip().split('\n')
|
|
345
|
lines = []
|
354
|
lines = []
|
|
346
|
for revline in revlines:
|
355
|
for revline in revlines:
|
|
347
|
time, rev = revline.split(' ')
|
356
|
time, rev = revline.split(' ')
|
|
|
|
|
|
|
361
|
|
370
|
|
|
362
|
# extensions
|
371
|
# extensions
|
|
363
|
self.extensions = {} # extension -> files, lines
|
372
|
self.extensions = {} # extension -> files, lines
|
|
364
|
- lines = getpipeoutput(['git ls-tree -r -z HEAD']).split('\000')
|
|
|
|
|
|
373
|
+ lines = getpipeoutput(['git ls-tree -r -z %s' % getcommitrange('HEAD', end_only = True)]).split('\000')
|
|
365
|
self.total_files = len(lines)
|
374
|
self.total_files = len(lines)
|
|
366
|
for line in lines:
|
375
|
for line in lines:
|
|
367
|
if len(line) == 0:
|
376
|
if len(line) == 0:
|
|
|
|
|
|
|
391
|
# N files changed, N insertions (+), N deletions(-)
|
400
|
# N files changed, N insertions (+), N deletions(-)
|
|
392
|
# <stamp> <author>
|
401
|
# <stamp> <author>
|
|
393
|
self.changes_by_date = {} # stamp -> { files, ins, del }
|
402
|
self.changes_by_date = {} # stamp -> { files, ins, del }
|
|
394
|
- lines = getpipeoutput(['git log --shortstat --pretty=format:"%at %an"']).split('\n')
|
|
|
|
|
|
403
|
+ lines = getpipeoutput(['git log --shortstat --pretty=format:"%%at %%an" %s' % getcommitrange('HEAD')]).split('\n')
|
|
395
|
lines.reverse()
|
404
|
lines.reverse()
|
|
396
|
files = 0; inserted = 0; deleted = 0; total_lines = 0
|
405
|
files = 0; inserted = 0; deleted = 0; total_lines = 0
|
|
397
|
author = None
|
406
|
author = None
|