remote-bzr: improve author sanitazion
So that we don't end up with '<None>', and also synchronize it with the one from remote-hg. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Felipe Contreras committed
Apr 30, 2013 at 20:10 UTC
3f6e7c0af18b5362d5d7b847d2b92ce38e72e030
1 file changed
+13
-2
contrib/remote-helpers/git-remote-bzr
+13
-2
@@ -38,6 +38,7 @@ import atexit, shutil, hashlib, urlparse, subprocess
38
39
NAME_RE = re.compile('^([^<>]+)')
40
AUTHOR_RE = re.compile('^([^<>]+?)? ?<([^<>]*)>$')
41
+EMAIL_RE = re.compile('^([^<>]+[^ \\\t<>])?\\b(?:[ \\t<>]*?)\\b([^ \\t<>]+@[^ \\t<>]+)')
42
RAW_AUTHOR_RE = re.compile('^(\w+) (.+)? <(.*)> (\d+) ([+-]\d+)')
43
44
def die(msg, *args):
@@ -175,9 +176,19 @@ def fixup_user(user):
176
name = m.group(1)
177
mail = m.group(2).strip()
178
else:
178
- m = NAME_RE.match(user)
179
+ m = EMAIL_RE.match(user)
180
if m:
180
- name = m.group(1).strip()
181
+ name = m.group(1)
182
+ mail = m.group(2)
183
+ else:
184
+ m = NAME_RE.match(user)
185
+ if m:
186
+ name = m.group(1).strip()
187
+
188
+ if not name:
189
+ name = 'unknown'
190
+ if not mail:
191
+ mail = 'Unknown'
192
193
return '%s <%s>' % (name, mail)
194