Skip to content

Commit c282315

Browse files
author
Sebastian Thiel
committed
Fix regex to support empty email addresses i.e. 'name <>'
Fixes gitpython-developers#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

+5
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 <[email protected]>"), Actor("name last another", "[email protected]"))
219+
215220
@ddt.data(('name', ''), ('name', 'prefix_'))
216221
def test_iterable_list(self, case):
217222
name, prefix = case

git/util.py

+2-2
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)