Skip to content

Commit 6c68a40

Browse files
rhansengitster
authored andcommitted
remote-bzr, remote-hg: fix email address regular expression
Before, strings like "[email protected]" would be converted to "foo. <[email protected]>" when they should be "unknown <[email protected]>". Signed-off-by: Richard Hansen <[email protected]> Reviewed-by: Felipe Contreras <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b2bff43 commit 6c68a40

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

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 < [email protected] >" "theta <[email protected]>" &&
216216
author_test iota "iota >[email protected]>" "iota <[email protected]>" &&
217217
author_test kappa "kappa < test <at> example <dot> com>" "kappa <unknown>" &&
218-
author_test lambda "[email protected]" "Unknown <[email protected]>"
218+
author_test lambda "[email protected]" "Unknown <[email protected]>" &&
219+
author_test mu "[email protected]" "Unknown <[email protected]>"
219220
) &&
220221
221222
git clone "hg::hgrepo" gitrepo &&

0 commit comments

Comments
 (0)