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>
Richard Hansen committed
Nov 17, 2013 at 23:12 UTC
6c68a404e6e9eec850b298f98fa30c5a25aa846e
3 files changed
+8
-9
contrib/remote-helpers/git-remote-bzr
+3
-4
@@ -44,8 +44,8 @@ import StringIO
44
import atexit, shutil, hashlib, urlparse, subprocess
45
46
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<>]+)')
49
RAW_AUTHOR_RE = re.compile('^(\w+) (.+)? <(.*)> (\d+) ([+-]\d+)')
50
51
def die(msg, *args):
@@ -193,8 +193,7 @@ def fixup_user(user):
193
else:
194
m = EMAIL_RE.match(user)
195
if m:
196
- name = m.group(1)
197
- mail = m.group(2)
196
+ mail = m.group(1)
197
else:
198
m = NAME_RE.match(user)
199
if m:
contrib/remote-helpers/git-remote-hg
+3
-4
@@ -51,8 +51,8 @@ import time as ptime
51
#
52
53
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<>]+)')
56
AUTHOR_HG_RE = re.compile('^(.*?) ?<(.*?)(?:>(.+)?)?$')
57
RAW_AUTHOR_RE = re.compile('^(\w+) (?:(.+)? )?<(.*)> (\d+) ([+-]\d+)')
58
@@ -316,8 +316,7 @@ def fixup_user_git(user):
316
else:
317
m = EMAIL_RE.match(user)
318
if m:
319
- name = m.group(1)
320
- mail = m.group(2)
319
+ mail = m.group(1)
320
else:
321
m = NAME_RE.match(user)
322
if m:
contrib/remote-helpers/test-hg.sh
+2
-1
@@ -215,7 +215,8 @@ test_expect_success 'authors' '
215
author_test theta "theta < test@example.com >" "theta <test@example.com>" &&
216
author_test iota "iota >test@example.com>" "iota <test@example.com>" &&
217
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>"
220
) &&
221
222
git clone "hg::hgrepo" gitrepo &&