remote-bzr, remote-hg: fix email address regular expression
authorRichard Hansen <rhansen@bbn.com>
Mon, 18 Nov 2013 04:12:50 +0000 (23:12 -0500)
committerJunio C Hamano <gitster@pobox.com>
Mon, 18 Nov 2013 21:46:00 +0000 (13:46 -0800)
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>
contrib/remote-helpers/git-remote-bzr
contrib/remote-helpers/git-remote-hg
contrib/remote-helpers/test-hg.sh
index 054161ae21b0c884d314c984992a6c7aa8276a96..7e345320ada69f1cbb909130d406cf08ce9ae130 100755 (executable)
@@ -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):
@@ -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:
index c6026b9bed37a91e30a278a02013072d21507061..30402d55323488f7c2bc6599bbc4a471f2120b33 100755 (executable)
@@ -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+)')
 
@@ -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:
index 642ad938cd3202eafeeb61a1dd95d9acfdab71a0..347e812923a20652b964db6b820f8f08d6c0795f 100755 (executable)
@@ -215,7 +215,8 @@ test_expect_success 'authors' '
        author_test theta "theta < test@example.com >" "theta <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 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 &&