Skip to content

Commit 6c68a40

Browse files
rhansengitster
authored andcommitted
remote-bzr, remote-hg: fix email address regular expression
Before, strings like "foo.bar@example.com" would be converted to "foo. <bar@example.com>" when they should be "unknown <foo.bar@example.com>". Signed-off-by: Richard Hansen <rhansen@bbn.com> Reviewed-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent b2bff43 commit 6c68a40

3 files changed

Lines changed: 8 additions & 9 deletions

File tree

contrib/remote-helpers/git-remote-bzr

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ import StringIO
4444
import atexit, shutil, hashlib, urlparse, subprocess
4545

4646
NAME_RE = re.compile('^([^<>]+)')
47-
AUTHOR_RE = re.compile('^([^<>]+?)? ?<([^<>]*)>$')
48-
EMAIL_RE = re.compile('^([^<>]+[^ \\\t<>])?\\b(?:[ \\t<>]*?)\\b([^ \\t<>]+@[^ \\t<>]+)')
47+
AUTHOR_RE = re.compile('^([^<>]+?)? ?[<>]([^<>]*)(?:$|>)')
48+
EMAIL_RE = re.compile(r'([^ \t<>]+@[^ \t<>]+)')
4949
RAW_AUTHOR_RE = re.compile('^(\w+) (.+)? <(.*)> (\d+) ([+-]\d+)')
5050

5151
def die(msg, *args):
@@ -193,8 +193,7 @@ def fixup_user(user):
193193
else:
194194
m = EMAIL_RE.match(user)
195195
if m:
196-
name = m.group(1)
197-
mail = m.group(2)
196+
mail = m.group(1)
198197
else:
199198
m = NAME_RE.match(user)
200199
if m:

contrib/remote-helpers/git-remote-hg

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ import time as ptime
5151
#
5252

5353
NAME_RE = re.compile('^([^<>]+)')
54-
AUTHOR_RE = re.compile('^([^<>]+?)? ?<([^<>]*)>$')
55-
EMAIL_RE = re.compile('^([^<>]+[^ \\\t<>])?\\b(?:[ \\t<>]*?)\\b([^ \\t<>]+@[^ \\t<>]+)')
54+
AUTHOR_RE = re.compile('^([^<>]+?)? ?[<>]([^<>]*)(?:$|>)')
55+
EMAIL_RE = re.compile(r'([^ \t<>]+@[^ \t<>]+)')
5656
AUTHOR_HG_RE = re.compile('^(.*?) ?<(.*?)(?:>(.+)?)?$')
5757
RAW_AUTHOR_RE = re.compile('^(\w+) (?:(.+)? )?<(.*)> (\d+) ([+-]\d+)')
5858

@@ -316,8 +316,7 @@ def fixup_user_git(user):
316316
else:
317317
m = EMAIL_RE.match(user)
318318
if m:
319-
name = m.group(1)
320-
mail = m.group(2)
319+
mail = m.group(1)
321320
else:
322321
m = NAME_RE.match(user)
323322
if m:

contrib/remote-helpers/test-hg.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ test_expect_success 'authors' '
215215
author_test theta "theta < test@example.com >" "theta <test@example.com>" &&
216216
author_test iota "iota >test@example.com>" "iota <test@example.com>" &&
217217
author_test kappa "kappa < test <at> example <dot> com>" "kappa <unknown>" &&
218-
author_test lambda "lambda@example.com" "Unknown <lambda@example.com>"
218+
author_test lambda "lambda@example.com" "Unknown <lambda@example.com>" &&
219+
author_test mu "mu.mu@example.com" "Unknown <mu.mu@example.com>"
219220
) &&
220221
221222
git clone "hg::hgrepo" gitrepo &&

0 commit comments

Comments
 (0)