Skip to content

Commit 3f6e7c0

Browse files
felipecgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c95c35f commit 3f6e7c0

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

contrib/remote-helpers/git-remote-bzr

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import atexit, shutil, hashlib, urlparse, subprocess
3838

3939
NAME_RE = re.compile('^([^<>]+)')
4040
AUTHOR_RE = re.compile('^([^<>]+?)? ?<([^<>]*)>$')
41+
EMAIL_RE = re.compile('^([^<>]+[^ \\\t<>])?\\b(?:[ \\t<>]*?)\\b([^ \\t<>]+@[^ \\t<>]+)')
4142
RAW_AUTHOR_RE = re.compile('^(\w+) (.+)? <(.*)> (\d+) ([+-]\d+)')
4243

4344
def die(msg, *args):
@@ -175,9 +176,19 @@ def fixup_user(user):
175176
name = m.group(1)
176177
mail = m.group(2).strip()
177178
else:
178-
m = NAME_RE.match(user)
179+
m = EMAIL_RE.match(user)
179180
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'
181192

182193
return '%s <%s>' % (name, mail)
183194

0 commit comments

Comments
 (0)