Ver código fonte

Fixed handling of weird author e-mails.

Commit e5fc428ecf3b23ed6b1a640bbddff9a59b251969 broke for linux-2.6 repository
for example, so we make a little bit more effort in handling weird e-mail
addresses. The linux-2.6 repository contains quite a few of these, some can be
found with the following command:

git rev-list --pretty=format:"%H %an <%aE>" HEAD | grep -v ^commit |grep -v '@'
Heikki Hokkanen 16 anos atrás
pai
commit
48e0acd6fb
1 arquivos alterados com 7 adições e 6 exclusões
  1. 7
    6
      gitstats

+ 7
- 6
gitstats Ver arquivo

@@ -227,19 +227,20 @@ class GitDataCollector(DataCollector):
227 227
 				self.tags[tag]['authors'][author] = commits
228 228
 
229 229
 		# Collect revision statistics
230
-		# Outputs "<stamp> <author>"
231
-		lines = getpipeoutput(['git rev-list --pretty=format:"%at %ai %aE %an" HEAD', 'grep -v ^commit']).split('\n')
230
+		# Outputs "<stamp> <date> <time> <timezone> <author> '<' <mail> '>'"
231
+		lines = getpipeoutput(['git rev-list --pretty=format:"%at %ai %an <%aE>" HEAD', 'grep -v ^commit']).split('\n')
232 232
 		for line in lines:
233
-			parts = line.split(' ')
233
+			parts = line.split(' ', 4)
234 234
 			author = ''
235 235
 			try:
236 236
 				stamp = int(parts[0])
237 237
 			except ValueError:
238 238
 				stamp = 0
239 239
 			timezone = parts[3]
240
-			domain = parts[4].rsplit('@', 1)[1]
241
-			if len(parts) > 5:
242
-				author = ' '.join(parts[5:])
240
+			author, mail = parts[4].split('<', 1)
241
+			author = author.rstrip()
242
+			mail = mail.rstrip('>')
243
+			domain = mail.rsplit('@', 1)[1]
243 244
 			date = datetime.datetime.fromtimestamp(float(stamp))
244 245
 
245 246
 			# First and last commit stamp