|
|
@@ -128,17 +128,9 @@ class GitDataCollector(DataCollector):
|
|
128
|
128
|
pass
|
|
129
|
129
|
|
|
130
|
130
|
# Collect revision statistics
|
|
131
|
|
- # "commit <hash>"
|
|
132
|
|
- # "<stamp> <author>"
|
|
133
|
|
- self.files_by_stamp = {} # stamp -> files
|
|
134
|
|
- lines = getoutput('git-rev-list --pretty=format:"%at %an" HEAD').split('\n')
|
|
135
|
|
- self.total_commits = len(lines) / 2
|
|
136
|
|
- commit = '0'
|
|
|
131
|
+ # Outputs "<stamp> <author>"
|
|
|
132
|
+ lines = getoutput('git-rev-list --pretty=format:"%at %an" HEAD |grep -v ^commit').split('\n')
|
|
137
|
133
|
for line in lines:
|
|
138
|
|
- if line[0] == 'c':
|
|
139
|
|
- commit = line[7:]
|
|
140
|
|
- continue
|
|
141
|
|
-
|
|
142
|
134
|
# linux-2.6 says "<unknown>" for one line O_o
|
|
143
|
135
|
parts = line.split(' ')
|
|
144
|
136
|
author = ''
|
|
|
@@ -226,14 +218,20 @@ class GitDataCollector(DataCollector):
|
|
226
|
218
|
else:
|
|
227
|
219
|
self.commits_by_year[yy] = 1
|
|
228
|
220
|
|
|
229
|
|
- # file statistics
|
|
230
|
|
- # "<stamp> <files>"
|
|
|
221
|
+ # TODO Optimize this, it's the worst bottleneck
|
|
|
222
|
+ # outputs "<stamp> <files>" for each revision
|
|
|
223
|
+ self.files_by_stamp = {} # stamp -> files
|
|
|
224
|
+ lines = getoutput('git-rev-list --pretty=format:"%at %H" HEAD |grep -v ^commit |while read line; do set $line; echo "$1 $(git-ls-tree -r "$2" |wc -l)"; done').split('\n')
|
|
|
225
|
+ self.total_commits = len(lines)
|
|
|
226
|
+ for line in lines:
|
|
|
227
|
+ parts = line.split(' ')
|
|
|
228
|
+ if len(parts) != 2:
|
|
|
229
|
+ continue
|
|
|
230
|
+ (stamp, files) = parts[0:2]
|
|
231
|
231
|
try:
|
|
232
|
|
- files = int(getoutput('git-ls-tree -r "%s" |wc -l' % commit, quiet = True))
|
|
|
232
|
+ self.files_by_stamp[int(stamp)] = int(files)
|
|
233
|
233
|
except ValueError:
|
|
234
|
|
- files = 0
|
|
235
|
|
- print 'Warning: failed to collect file statistics for commit "%s"' % commit
|
|
236
|
|
- self.files_by_stamp[stamp] = files
|
|
|
234
|
+ print 'Warning: failed to parse line "%s"' % line
|
|
237
|
235
|
|
|
238
|
236
|
# extensions
|
|
239
|
237
|
self.extensions = {} # extension -> files, lines
|