|
|
@@ -63,11 +63,11 @@ class DataCollector:
|
|
63
|
63
|
##
|
|
64
|
64
|
# Load cacheable data
|
|
65
|
65
|
def loadCache(self, dir):
|
|
66
|
|
- cachefile = os.path.join(dir, 'gitstats.cache')
|
|
|
66
|
+ cachefile = os.path.join(dir, '.git', 'gitstats.cache')
|
|
67
|
67
|
if not os.path.exists(cachefile):
|
|
68
|
68
|
return
|
|
69
|
69
|
print 'Loading cache...'
|
|
70
|
|
- f = open(os.path.join(dir, 'gitstats.cache'))
|
|
|
70
|
+ f = open(cachefile)
|
|
71
|
71
|
self.cache = pickle.load(f)
|
|
72
|
72
|
f.close()
|
|
73
|
73
|
|
|
|
@@ -120,7 +120,7 @@ class DataCollector:
|
|
120
|
120
|
# Save cacheable data
|
|
121
|
121
|
def saveCache(self, dir):
|
|
122
|
122
|
print 'Saving cache...'
|
|
123
|
|
- f = open(os.path.join(dir, 'gitstats.cache'), 'w')
|
|
|
123
|
+ f = open(os.path.join(dir, '.git', 'gitstats.cache'), 'w')
|
|
124
|
124
|
pickle.dump(self.cache, f)
|
|
125
|
125
|
f.close()
|
|
126
|
126
|
|
|
|
@@ -266,7 +266,8 @@ class GitDataCollector(DataCollector):
|
|
266
|
266
|
lines = []
|
|
267
|
267
|
for revline in revlines:
|
|
268
|
268
|
time, rev = revline.split(' ')
|
|
269
|
|
- linecount = int(getpipeoutput(['git-ls-tree -r --name-only "%s"' % rev, 'wc -l']).split('\n')[0])
|
|
|
269
|
+ #linecount = int(getpipeoutput(['git-ls-tree -r --name-only "%s"' % rev, 'wc -l']).split('\n')[0])
|
|
|
270
|
+ linecount = self.getFilesInCommit(rev)
|
|
270
|
271
|
lines.append('%d %d' % (int(time), linecount))
|
|
271
|
272
|
|
|
272
|
273
|
self.total_commits = len(lines)
|
|
|
@@ -366,6 +367,17 @@ class GitDataCollector(DataCollector):
|
|
366
|
367
|
def getAuthors(self):
|
|
367
|
368
|
return self.authors.keys()
|
|
368
|
369
|
|
|
|
370
|
+ def getFilesInCommit(self, rev):
|
|
|
371
|
+ try:
|
|
|
372
|
+ res = self.cache['files_in_tree'][rev]
|
|
|
373
|
+ except:
|
|
|
374
|
+ res = int(getpipeoutput(['git-ls-tree -r --name-only "%s"' % rev, 'wc -l']).split('\n')[0])
|
|
|
375
|
+ if 'files_in_tree' not in self.cache:
|
|
|
376
|
+ self.cache['files_in_tree'] = {}
|
|
|
377
|
+ self.cache['files_in_tree'][rev] = res
|
|
|
378
|
+
|
|
|
379
|
+ return res
|
|
|
380
|
+
|
|
369
|
381
|
def getFirstCommitDate(self):
|
|
370
|
382
|
return datetime.datetime.fromtimestamp(self.first_commit_stamp)
|
|
371
|
383
|
|