summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Thiel <sthiel@thoughtworks.com>2019-07-06 10:41:42 +0800
committerSebastian Thiel <sthiel@thoughtworks.com>2019-07-06 10:41:42 +0800
commitc282315f0b533c3790494767d1da23aaa9d360b9 (patch)
tree335b20cc61fd8222f6236911b3d391b162c7a985
parent77e47bc313e42f9636e37ec94f2e0b366b492836 (diff)
downloadgitpython-c282315f0b533c3790494767d1da23aaa9d360b9.tar.gz
Fix regex to support empty email addresses i.e. 'name <>'
Fixes #833
-rw-r--r--git/test/test_util.py5
-rw-r--r--git/util.py4
2 files changed, 7 insertions, 2 deletions
diff --git a/git/test/test_util.py b/git/test/test_util.py
index 9c993205..3f5e4abe 100644
--- a/git/test/test_util.py
+++ b/git/test/test_util.py
@@ -212,6 +212,11 @@ class TestUtils(TestBase):
self.assertIsInstance(Actor.author(cr), Actor)
# END assure config reader is handled
+ def test_actor_from_string(self):
+ self.assertEqual(Actor._from_string("name"), Actor("name", None))
+ self.assertEqual(Actor._from_string("name <>"), Actor("name", ""))
+ self.assertEqual(Actor._from_string("name last another <some-very-long-email@example.com>"), Actor("name last another", "some-very-long-email@example.com"))
+
@ddt.data(('name', ''), ('name', 'prefix_'))
def test_iterable_list(self, case):
name, prefix = case
diff --git a/git/util.py b/git/util.py
index a3b1fbfb..3ba58857 100644
--- a/git/util.py
+++ b/git/util.py
@@ -534,8 +534,8 @@ class Actor(object):
can be committers and authors or anything with a name and an email as
mentioned in the git log entries."""
# PRECOMPILED REGEX
- name_only_regex = re.compile(r'<(.+)>')
- name_email_regex = re.compile(r'(.*) <(.+?)>')
+ name_only_regex = re.compile(r'<(.*)>')
+ name_email_regex = re.compile(r'(.*) <(.*?)>')
# ENVIRONMENT VARIABLES
# read when creating new commits