Skip to content

Commit c282315

Browse files
author
Sebastian Thiel
committed
Fix regex to support empty email addresses i.e. 'name <>'
Fixes #833
1 parent 77e47bc commit c282315

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

git/test/test_util.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@ def test_actor(self):
212212
self.assertIsInstance(Actor.author(cr), Actor)
213213
# END assure config reader is handled
214214

215+
def test_actor_from_string(self):
216+
self.assertEqual(Actor._from_string("name"), Actor("name", None))
217+
self.assertEqual(Actor._from_string("name <>"), Actor("name", ""))
218+
self.assertEqual(Actor._from_string("name last another <some-very-long-email@example.com>"), Actor("name last another", "some-very-long-email@example.com"))
219+
215220
@ddt.data(('name', ''), ('name', 'prefix_'))
216221
def test_iterable_list(self, case):
217222
name, prefix = case

git/util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,8 +534,8 @@ class Actor(object):
534534
can be committers and authors or anything with a name and an email as
535535
mentioned in the git log entries."""
536536
# PRECOMPILED REGEX
537-
name_only_regex = re.compile(r'<(.+)>')
538-
name_email_regex = re.compile(r'(.*) <(.+?)>')
537+
name_only_regex = re.compile(r'<(.*)>')
538+
name_email_regex = re.compile(r'(.*) <(.*?)>')
539539

540540
# ENVIRONMENT VARIABLES
541541
# read when creating new commits

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy