Explorar el Código

Fix first/last commit finding.

Because of cherry-pick and patches, commits may be in any order. This also
improves the support for generating statistics for multiple repositories.
Heikki Hokkanen hace 15 años
padre
commit
377e7f32e5
Se han modificado 1 ficheros con 13 adiciones y 6 borrados
  1. 13
    6
      gitstats

+ 13
- 6
gitstats Ver fichero

@@ -288,10 +288,12 @@ class GitDataCollector(DataCollector):
288 288
 				domain = mail.rsplit('@', 1)[1]
289 289
 			date = datetime.datetime.fromtimestamp(float(stamp))
290 290
 
291
-			# First and last commit stamp
292
-			if self.last_commit_stamp == 0:
291
+			# First and last commit stamp (may be in any order because of cherry-picking and patches)
292
+			if stamp > self.last_commit_stamp:
293 293
 				self.last_commit_stamp = stamp
294
-			self.first_commit_stamp = stamp
294
+				print 'Last:', stamp
295
+			if self.first_commit_stamp == 0 or stamp < self.first_commit_stamp:
296
+				self.first_commit_stamp = stamp
295 297
 
296 298
 			# activity
297 299
 			# hour
@@ -332,10 +334,15 @@ class GitDataCollector(DataCollector):
332 334
 			# author stats
333 335
 			if author not in self.authors:
334 336
 				self.authors[author] = {}
335
-			# commits
337
+			# commits, note again that commits may be in any date order because of cherry-picking and patches
336 338
 			if 'last_commit_stamp' not in self.authors[author]:
337 339
 				self.authors[author]['last_commit_stamp'] = stamp
338
-			self.authors[author]['first_commit_stamp'] = stamp
340
+			if stamp > self.authors[author]['last_commit_stamp']:
341
+				self.authors[author]['last_commit_stamp'] = stamp
342
+			if 'first_commit_stamp' not in self.authors[author]:
343
+				self.authors[author]['first_commit_stamp'] = stamp
344
+			if stamp < self.authors[author]['first_commit_stamp']:
345
+				self.authors[author]['first_commit_stamp'] = stamp
339 346
 
340 347
 			# author of the month/year
341 348
 			yymm = date.strftime('%Y-%m')
@@ -523,7 +530,7 @@ class GitDataCollector(DataCollector):
523 530
 			delta = date_last - date_first
524 531
 			a['date_first'] = date_first.strftime('%Y-%m-%d')
525 532
 			a['date_last'] = date_last.strftime('%Y-%m-%d')
526
-			a['timedelta'] = abs(delta)
533
+			a['timedelta'] = delta
527 534
 			if 'lines_added' not in a: a['lines_added'] = 0
528 535
 			if 'lines_removed' not in a: a['lines_removed'] = 0
529 536