44# This module is part of GitPython and is released under
55# the BSD License: http://www.opensource.org/licenses/bsd-license.php
66
7- import re
8- import time
97from git .utils import Iterable
10- from git .actor import Actor
118import git .diff as diff
129import git .stats as stats
1310from tree import Tree
1411import base
12+ import utils
1513
1614class Commit (base .Object , Iterable ):
1715 """
@@ -20,8 +18,6 @@ class Commit(base.Object, Iterable):
2018 This class will act lazily on some of its attributes and will query the
2119 value on demand only if it involves calling the git binary.
2220 """
23- # precompiled regex
24- re_actor_epoch = re .compile (r'^.+? (.*) (\d+) .*$' )
2521
2622 # object configuration
2723 type = "commit"
@@ -48,14 +44,16 @@ def __init__(self, repo, id, tree=None, author=None, authored_date=None,
4844 ``author`` : Actor
4945 is the author string ( will be implicitly converted into an Actor object )
5046
51- ``authored_date`` : (tm_year, tm_mon, tm_mday, tm_hour, tm_min, tm_sec, tm_wday, tm_yday, tm_isdst )
52- is the authored DateTime
47+ ``authored_date`` : int_seconds_since_epoch
48+ is the authored DateTime - use time.gmtime() to convert it into a
49+ different format
5350
5451 ``committer`` : Actor
5552 is the committer string
5653
57- ``committed_date`` : (tm_year, tm_mon, tm_mday, tm_hour, tm_min, tm_sec, tm_wday, tm_yday, tm_isdst)
58- is the committed DateTime
54+ ``committed_date`` : int_seconds_since_epoch
55+ is the committed DateTime - use time.gmtime() to convert it into a
56+ different format
5957
6058 ``message`` : string
6159 is the commit message
@@ -185,8 +183,8 @@ def _iter_from_process_or_stream(cls, repo, proc_or_stream):
185183 parents .append (parent_line .split ()[- 1 ])
186184 # END for each parent line
187185
188- author , authored_date = cls . _actor (next_line )
189- committer , committed_date = cls . _actor (stream .next ())
186+ author , authored_date = utils . parse_actor_and_date (next_line )
187+ committer , committed_date = utils . parse_actor_and_date (stream .next ())
190188
191189 # empty line
192190 stream .next ()
@@ -286,14 +284,3 @@ def __str__(self):
286284 def __repr__ (self ):
287285 return '<git.Commit "%s">' % self .id
288286
289- @classmethod
290- def _actor (cls , line ):
291- """
292- Parse out the actor (author or committer) info
293-
294- Returns
295- [Actor, gmtime(acted at time)]
296- """
297- m = cls .re_actor_epoch .search (line )
298- actor , epoch = m .groups ()
299- return (Actor ._from_string (actor ), time .gmtime (int (epoch )))
0 commit comments