Bladeren bron

Merge 0c643be0f1b2fb8792621ebe07f103b797dd7f4c into 55c5c285558c410bb35ebf421245d320ab9ee9fa

Dirk-Willem van Gulik 7 jaren geleden
bovenliggende
commit
d9631de8ae
Geen account gekoppeld aan de committers e-mail
1 gewijzigde bestanden met toevoegingen van 17 en 3 verwijderingen
  1. 17
    3
      gitstats

+ 17
- 3
gitstats Bestand weergeven

@@ -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():