summaryrefslogtreecommitdiff
path: root/lib/git/objects/commit.py
diff options
context:
space:
mode:
authorRick Copeland <rcopeland@geek.net>2010-04-27 16:34:39 -0400
committerRick Copeland <rcopeland@geek.net>2010-04-27 16:38:35 -0400
commitb48e4d3aa853687f420dc51969837734b70bfdec (patch)
tree6d33df26dffe527e9a2c3835f8cae379b836a1f4 /lib/git/objects/commit.py
parent82b8902e033430000481eb355733cd7065342037 (diff)
downloadgitpython-b48e4d3aa853687f420dc51969837734b70bfdec.tar.gz
Add support for time zone information in tags and commits.
This commit includes - an update to git.objects.utils:parse_actor_and_date to parse the timezone offset - updates to the git.objects.Commit and git.objects.Tag objects to support *_tz_offset attributes - updates to tests in test.git.test_commit and test.git.test_refs to check for appropriate *_tz_offset attributes
Diffstat (limited to 'lib/git/objects/commit.py')
-rw-r--r--lib/git/objects/commit.py28
1 files changed, 20 insertions, 8 deletions
diff --git a/lib/git/objects/commit.py b/lib/git/objects/commit.py
index d1bbb889..4a0e278d 100644
--- a/lib/git/objects/commit.py
+++ b/lib/git/objects/commit.py
@@ -23,12 +23,14 @@ class Commit(base.Object, Iterable, diff.Diffable, utils.Traversable):
# object configuration
type = "commit"
- __slots__ = ("tree", "author", "authored_date", "committer", "committed_date",
- "message", "parents")
+ __slots__ = ("tree",
+ "author", "authored_date", "author_tz_offset",
+ "committer", "committed_date", "committer_tz_offset",
+ "message", "parents")
_id_attribute_ = "sha"
- def __init__(self, repo, sha, tree=None, author=None, authored_date=None,
- committer=None, committed_date=None, message=None, parents=None):
+ def __init__(self, repo, sha, tree=None, author=None, authored_date=None, author_tz_offset=None,
+ committer=None, committed_date=None, committer_tz_offset=None, message=None, parents=None):
"""
Instantiate a new Commit. All keyword arguments taking None as default will
be implicitly set if id names a valid sha.
@@ -51,6 +53,9 @@ class Commit(base.Object, Iterable, diff.Diffable, utils.Traversable):
is the authored DateTime - use time.gmtime() to convert it into a
different format
+ ``author_tz_offset``: int_seconds_west_of_utc
+ is the timezone that the authored_date is in
+
``committer`` : Actor
is the committer string
@@ -58,6 +63,9 @@ class Commit(base.Object, Iterable, diff.Diffable, utils.Traversable):
is the committed DateTime - use time.gmtime() to convert it into a
different format
+ ``committer_tz_offset``: int_seconds_west_of_utc
+ is the timezone that the authored_date is in
+
``message`` : string
is the commit message
@@ -94,8 +102,10 @@ class Commit(base.Object, Iterable, diff.Diffable, utils.Traversable):
self.tree = temp.tree
self.author = temp.author
self.authored_date = temp.authored_date
+ self.author_tz_offset = temp.author_tz_offset
self.committer = temp.committer
self.committed_date = temp.committed_date
+ self.committer_tz_offset = temp.committer_tz_offset
self.message = temp.message
else:
super(Commit, self)._set_cache_(attr)
@@ -253,8 +263,8 @@ class Commit(base.Object, Iterable, diff.Diffable, utils.Traversable):
parents.append(parent_line.split()[-1])
# END for each parent line
- author, authored_date = utils.parse_actor_and_date(next_line)
- committer, committed_date = utils.parse_actor_and_date(stream.next())
+ author, authored_date, author_tz_offset = utils.parse_actor_and_date(next_line)
+ committer, committed_date, committer_tz_offset = utils.parse_actor_and_date(stream.next())
# empty line
stream.next()
@@ -276,8 +286,10 @@ class Commit(base.Object, Iterable, diff.Diffable, utils.Traversable):
# END message parsing
message = '\n'.join(message_lines)
- yield Commit(repo, id, parents=tuple(parents), tree=tree, author=author, authored_date=authored_date,
- committer=committer, committed_date=committed_date, message=message)
+ yield Commit(repo, id, parents=tuple(parents), tree=tree,
+ author=author, authored_date=authored_date, author_tz_offset=author_tz_offset,
+ committer=committer, committed_date=committed_date, committer_tz_offset=committer_tz_offset,
+ message=message)
# END for each line in stream