Skip to content

Fixed parse_actor_and_date with mangled tags #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion git/objects/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,21 @@ def parse_date(string_date):

# precompiled regex
_re_actor_epoch = re.compile(r'^.+? (.*) (\d+) ([+-]\d+).*$')
_re_only_actor = re.compile(r'^.+? (.*)$')

def parse_actor_and_date(line):
"""Parse out the actor (author or committer) info from a line like::

author Tom Preston-Werner <tom@mojombo.com> 1191999972 -0700

:return: [Actor, int_seconds_since_epoch, int_timezone_offset]"""
actor, epoch, offset = '', 0, 0
m = _re_actor_epoch.search(line)
actor, epoch, offset = m.groups()
if m:
actor, epoch, offset = m.groups()
else:
m = _re_only_actor.search(line)
actor = _re_only_actor.search(line).group(1) if m else line or ''
return (Actor._from_string(actor), int(epoch), utctz_to_altz(offset))


Expand Down