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>
This commit is contained in:

committed by
Junio C Hamano

parent
b2bff43170
commit
6c68a404e6
@ -44,8 +44,8 @@ import StringIO
|
|||||||
import atexit, shutil, hashlib, urlparse, subprocess
|
import atexit, shutil, hashlib, urlparse, subprocess
|
||||||
|
|
||||||
NAME_RE = re.compile('^([^<>]+)')
|
NAME_RE = re.compile('^([^<>]+)')
|
||||||
AUTHOR_RE = re.compile('^([^<>]+?)? ?<([^<>]*)>$')
|
AUTHOR_RE = re.compile('^([^<>]+?)? ?[<>]([^<>]*)(?:$|>)')
|
||||||
EMAIL_RE = re.compile('^([^<>]+[^ \\\t<>])?\\b(?:[ \\t<>]*?)\\b([^ \\t<>]+@[^ \\t<>]+)')
|
EMAIL_RE = re.compile(r'([^ \t<>]+@[^ \t<>]+)')
|
||||||
RAW_AUTHOR_RE = re.compile('^(\w+) (.+)? <(.*)> (\d+) ([+-]\d+)')
|
RAW_AUTHOR_RE = re.compile('^(\w+) (.+)? <(.*)> (\d+) ([+-]\d+)')
|
||||||
|
|
||||||
def die(msg, *args):
|
def die(msg, *args):
|
||||||
@ -193,8 +193,7 @@ def fixup_user(user):
|
|||||||
else:
|
else:
|
||||||
m = EMAIL_RE.match(user)
|
m = EMAIL_RE.match(user)
|
||||||
if m:
|
if m:
|
||||||
name = m.group(1)
|
mail = m.group(1)
|
||||||
mail = m.group(2)
|
|
||||||
else:
|
else:
|
||||||
m = NAME_RE.match(user)
|
m = NAME_RE.match(user)
|
||||||
if m:
|
if m:
|
||||||
|
@ -51,8 +51,8 @@ import time as ptime
|
|||||||
#
|
#
|
||||||
|
|
||||||
NAME_RE = re.compile('^([^<>]+)')
|
NAME_RE = re.compile('^([^<>]+)')
|
||||||
AUTHOR_RE = re.compile('^([^<>]+?)? ?<([^<>]*)>$')
|
AUTHOR_RE = re.compile('^([^<>]+?)? ?[<>]([^<>]*)(?:$|>)')
|
||||||
EMAIL_RE = re.compile('^([^<>]+[^ \\\t<>])?\\b(?:[ \\t<>]*?)\\b([^ \\t<>]+@[^ \\t<>]+)')
|
EMAIL_RE = re.compile(r'([^ \t<>]+@[^ \t<>]+)')
|
||||||
AUTHOR_HG_RE = re.compile('^(.*?) ?<(.*?)(?:>(.+)?)?$')
|
AUTHOR_HG_RE = re.compile('^(.*?) ?<(.*?)(?:>(.+)?)?$')
|
||||||
RAW_AUTHOR_RE = re.compile('^(\w+) (?:(.+)? )?<(.*)> (\d+) ([+-]\d+)')
|
RAW_AUTHOR_RE = re.compile('^(\w+) (?:(.+)? )?<(.*)> (\d+) ([+-]\d+)')
|
||||||
|
|
||||||
@ -316,8 +316,7 @@ def fixup_user_git(user):
|
|||||||
else:
|
else:
|
||||||
m = EMAIL_RE.match(user)
|
m = EMAIL_RE.match(user)
|
||||||
if m:
|
if m:
|
||||||
name = m.group(1)
|
mail = m.group(1)
|
||||||
mail = m.group(2)
|
|
||||||
else:
|
else:
|
||||||
m = NAME_RE.match(user)
|
m = NAME_RE.match(user)
|
||||||
if m:
|
if m:
|
||||||
|
@ -215,7 +215,8 @@ test_expect_success 'authors' '
|
|||||||
author_test theta "theta < test@example.com >" "theta <test@example.com>" &&
|
author_test theta "theta < test@example.com >" "theta <test@example.com>" &&
|
||||||
author_test iota "iota >test@example.com>" "iota <test@example.com>" &&
|
author_test iota "iota >test@example.com>" "iota <test@example.com>" &&
|
||||||
author_test kappa "kappa < test <at> example <dot> com>" "kappa <unknown>" &&
|
author_test kappa "kappa < test <at> example <dot> com>" "kappa <unknown>" &&
|
||||||
author_test lambda "lambda@example.com" "Unknown <lambda@example.com>"
|
author_test lambda "lambda@example.com" "Unknown <lambda@example.com>" &&
|
||||||
|
author_test mu "mu.mu@example.com" "Unknown <mu.mu@example.com>"
|
||||||
) &&
|
) &&
|
||||||
|
|
||||||
git clone "hg::hgrepo" gitrepo &&
|
git clone "hg::hgrepo" gitrepo &&
|
||||||
|
Reference in New Issue
Block a user