Bläddra i källkod

Add a new option 'linear_linestats' (default on).

When enabled, the lines of code statistics are collected from linear history.
The downside is that commits of feature long feature branches appear only at
the point where a merge commit is made.

If disabled (old behaviour), the problem is that if two branches contain the
same changes (for example, removal of same lines), the statistics get skewed.

Fixes line count statistics for this example repository:
git://github.com/septract/jstar.git

Thanks-to: Radu Grigore <radugrigore@users.sourceforge.net>
Heikki Hokkanen 15 år sedan
förälder
incheckning
0656ac9578
1 ändrade filer med 7 tillägg och 1 borttagningar
  1. 7
    1
      gitstats

+ 7
- 1
gitstats Visa fil

@@ -36,6 +36,7 @@ conf = {
36 36
 	'authors_top': 5,
37 37
 	'commit_begin': '',
38 38
 	'commit_end': '',
39
+	'linear_linestats': 1,
39 40
 }
40 41
 
41 42
 def getpipeoutput(cmds, quiet = False):
@@ -400,7 +401,10 @@ class GitDataCollector(DataCollector):
400 401
 		#  N files changed, N insertions (+), N deletions(-)
401 402
 		# <stamp> <author>
402 403
 		self.changes_by_date = {} # stamp -> { files, ins, del }
403
-		lines = getpipeoutput(['git log --shortstat --pretty=format:"%%at %%aN" %s' % getcommitrange('HEAD')]).split('\n')
404
+		extra = ''
405
+		if conf['linear_linestats']:
406
+			extra = '--first-parent -m'
407
+		lines = getpipeoutput(['git log --shortstat %s --pretty=format:"%%at %%aN" %s' % (extra, getcommitrange('HEAD'))]).split('\n')
404 408
 		lines.reverse()
405 409
 		files = 0; inserted = 0; deleted = 0; total_lines = 0
406 410
 		author = None
@@ -455,6 +459,8 @@ class GitDataCollector(DataCollector):
455 459
 			a['date_first'] = date_first.strftime('%Y-%m-%d')
456 460
 			a['date_last'] = date_last.strftime('%Y-%m-%d')
457 461
 			a['timedelta'] = delta
462
+			if 'lines_added' not in a: a['lines_added'] = 0
463
+			if 'lines_removed' not in a: a['lines_removed'] = 0
458 464
 	
459 465
 	def getActiveDays(self):
460 466
 		return self.active_days