Pārlūkot izejas kodu

Minor tweak to allow date ranges. Double quote dance is to also let commit sequences still work. Addtional 'ignores' to trap issues with empty results due to the narrow ranges now more easily elicited.

Dirk-Willem van Gulik 7 gadus atpakaļ
vecāks
revīzija
0c643be0f1
1 mainītis faili ar 17 papildinājumiem un 3 dzēšanām
  1. 17
    3
      gitstats

+ 17
- 3
gitstats Parādīt failu

@@ -47,7 +47,8 @@ conf = {
47 47
 	'linear_linestats': 1,
48 48
 	'project_name': '',
49 49
 	'processes': 8,
50
-	'start_date': ''
50
+	'start_date': '',
51
+	'end_date': '',
51 52
 }
52 53
 
53 54
 def getpipeoutput(cmds, quiet = False):
@@ -74,8 +75,13 @@ def getpipeoutput(cmds, quiet = False):
74 75
 
75 76
 def getlogrange(defaultrange = 'HEAD', end_only = True):
76 77
 	commit_range = getcommitrange(defaultrange, end_only)
78
+        datesel = ''
77 79
 	if len(conf['start_date']) > 0:
78
-		return '--since="%s" "%s"' % (conf['start_date'], commit_range)
80
+		datesel = '--since="%s" %s' % (conf['start_date'], datesel)
81
+	if len(conf['end_date']) > 0:
82
+		datesel = '--until="%s" %s' % (conf['end_date'], datesel)
83
+        if (len(datesel) > 0):
84
+		commit_range = '%s "%s"' % (datesel, commit_range)
79 85
 	return commit_range
80 86
 
81 87
 def getcommitrange(defaultrange = 'HEAD', end_only = False):
@@ -330,6 +336,9 @@ class GitDataCollector(DataCollector):
330 336
 		lines = getpipeoutput(['git rev-list --pretty=format:"%%at %%ai %%aN <%%aE>" %s' % getlogrange('HEAD'), 'grep -v ^commit']).split('\n')
331 337
 		for line in lines:
332 338
 			parts = line.split(' ', 4)
339
+                        if (len(parts) != 4):
340
+				print 'Warning: failed to parse line "%s"' % line
341
+                                continue
333 342
 			author = ''
334 343
 			try:
335 344
 				stamp = int(parts[0])
@@ -441,7 +450,12 @@ class GitDataCollector(DataCollector):
441 450
 		#Look up rev in cache and take info from cache if found
442 451
 		#If not append rev to list of rev to read from repo
443 452
 		for revline in revlines:
444
-			time, rev = revline.split(' ')
453
+			try:
454
+                              time, rev = revline.split(' ')
455
+			except ValueError:
456
+				print 'Warning: failed to parse line "%s"' % line
457
+                                continue
458
+ 
445 459
 			#if cache empty then add time and rev to list of new rev's
446 460
 			#otherwise try to read needed info from cache
447 461
 			if 'files_in_tree' not in self.cache.keys():