浏览代码

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 15 年前
父节点
当前提交
377e7f32e5
共有 1 个文件被更改,包括 13 次插入6 次删除
  1. 13
    6
      gitstats

+ 13
- 6
gitstats 查看文件

288
 				domain = mail.rsplit('@', 1)[1]
288
 				domain = mail.rsplit('@', 1)[1]
289
 			date = datetime.datetime.fromtimestamp(float(stamp))
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
 				self.last_commit_stamp = stamp
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
 			# activity
298
 			# activity
297
 			# hour
299
 			# hour
332
 			# author stats
334
 			# author stats
333
 			if author not in self.authors:
335
 			if author not in self.authors:
334
 				self.authors[author] = {}
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
 			if 'last_commit_stamp' not in self.authors[author]:
338
 			if 'last_commit_stamp' not in self.authors[author]:
337
 				self.authors[author]['last_commit_stamp'] = stamp
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
 			# author of the month/year
347
 			# author of the month/year
341
 			yymm = date.strftime('%Y-%m')
348
 			yymm = date.strftime('%Y-%m')
523
 			delta = date_last - date_first
530
 			delta = date_last - date_first
524
 			a['date_first'] = date_first.strftime('%Y-%m-%d')
531
 			a['date_first'] = date_first.strftime('%Y-%m-%d')
525
 			a['date_last'] = date_last.strftime('%Y-%m-%d')
532
 			a['date_last'] = date_last.strftime('%Y-%m-%d')
526
-			a['timedelta'] = abs(delta)
533
+			a['timedelta'] = delta
527
 			if 'lines_added' not in a: a['lines_added'] = 0
534
 			if 'lines_added' not in a: a['lines_added'] = 0
528
 			if 'lines_removed' not in a: a['lines_removed'] = 0
535
 			if 'lines_removed' not in a: a['lines_removed'] = 0
529
 	
536