Skip to content

Commit

Permalink
remote-bzr, remote-hg: fix email address regular expression
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
rhansen authored and gitster committed Nov 18, 2013
1 parent b2bff43 commit 6c68a40
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
7 changes: 3 additions & 4 deletions contrib/remote-helpers/git-remote-bzr
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ import StringIO
import atexit, shutil, hashlib, urlparse, subprocess

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

def die(msg, *args):
Expand Down Expand Up @@ -193,8 +193,7 @@ def fixup_user(user):
else:
m = EMAIL_RE.match(user)
if m:
name = m.group(1)
mail = m.group(2)
mail = m.group(1)
else:
m = NAME_RE.match(user)
if m:
Expand Down
7 changes: 3 additions & 4 deletions contrib/remote-helpers/git-remote-hg
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ import time as ptime
#

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

Expand Down Expand Up @@ -316,8 +316,7 @@ def fixup_user_git(user):
else:
m = EMAIL_RE.match(user)
if m:
name = m.group(1)
mail = m.group(2)
mail = m.group(1)
else:
m = NAME_RE.match(user)
if m:
Expand Down
3 changes: 2 additions & 1 deletion contrib/remote-helpers/test-hg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ test_expect_success 'authors' '
author_test theta "theta < [email protected] >" "theta <[email protected]>" &&
author_test iota "iota >[email protected]>" "iota <[email protected]>" &&
author_test kappa "kappa < test <at> example <dot> com>" "kappa <unknown>" &&
author_test lambda "[email protected]" "Unknown <[email protected]>"
author_test lambda "[email protected]" "Unknown <[email protected]>" &&
author_test mu "[email protected]" "Unknown <[email protected]>"
) &&
git clone "hg::hgrepo" gitrepo &&
Expand Down

0 comments on commit 6c68a40

Please sign in to comment.