summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2010-04-30 09:30:05 +0200
committerSebastian Thiel <byronimo@gmail.com>2010-04-30 09:30:05 +0200
commitb75c3103a700ac65b6cd18f66e2d0a07cfc09797 (patch)
tree045df74b6615d2f8505199d5e71d07f40fc4edee /lib
parent69361d96a59381fde0ac34d19df2d4aff05fb9a9 (diff)
parentb48e4d3aa853687f420dc51969837734b70bfdec (diff)
downloadgitpython-b75c3103a700ac65b6cd18f66e2d0a07cfc09797.tar.gz
Merge commit 'refs/merge-requests/14' of git://gitorious.org/git-python/mainline into integration
Diffstat (limited to 'lib')
-rw-r--r--lib/git/objects/commit.py28
-rw-r--r--lib/git/objects/tag.py10
-rw-r--r--lib/git/objects/utils.py8
3 files changed, 31 insertions, 15 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
diff --git a/lib/git/objects/tag.py b/lib/git/objects/tag.py
index e880bbe5..96363db6 100644
--- a/lib/git/objects/tag.py
+++ b/lib/git/objects/tag.py
@@ -15,10 +15,10 @@ class TagObject(base.Object):
to.
"""
type = "tag"
- __slots__ = ( "object", "tag", "tagger", "tagged_date", "message" )
+ __slots__ = ( "object", "tag", "tagger", "tagged_date", "tagger_tz_offset", "message" )
def __init__(self, repo, sha, object=None, tag=None,
- tagger=None, tagged_date=None, message=None):
+ tagger=None, tagged_date=None, tagger_tz_offset=None, message=None):
"""
Initialize a tag object with additional data
@@ -40,6 +40,10 @@ class TagObject(base.Object):
``tagged_date`` : int_seconds_since_epoch
is the DateTime of the tag creation - use time.gmtime to convert
it into a different format
+
+ ``tagged_tz_offset``: int_seconds_west_of_utc
+ is the timezone that the authored_date is in
+
"""
super(TagObject, self).__init__(repo, sha )
self._set_self_from_args_(locals())
@@ -58,7 +62,7 @@ class TagObject(base.Object):
self.tag = lines[2][4:] # tag <tag name>
tagger_info = lines[3][7:]# tagger <actor> <date>
- self.tagger, self.tagged_date = utils.parse_actor_and_date(tagger_info)
+ self.tagger, self.tagged_date, self.tagger_tz_offset = utils.parse_actor_and_date(tagger_info)
# line 4 empty - it could mark the beginning of the next header
# in csse there really is no message, it would not exist. Otherwise
diff --git a/lib/git/objects/utils.py b/lib/git/objects/utils.py
index ec5453f1..4f17b652 100644
--- a/lib/git/objects/utils.py
+++ b/lib/git/objects/utils.py
@@ -39,7 +39,7 @@ def get_object_type_by_name(object_type_name):
# precompiled regex
-_re_actor_epoch = re.compile(r'^.+? (.*) (\d+) .*$')
+_re_actor_epoch = re.compile(r'^.+? (.*) (\d+) ([+-]\d+).*$')
def parse_actor_and_date(line):
"""
@@ -48,11 +48,11 @@ def parse_actor_and_date(line):
author Tom Preston-Werner <tom@mojombo.com> 1191999972 -0700
Returns
- [Actor, int_seconds_since_epoch]
+ [Actor, int_seconds_since_epoch, int_timezone_offset]
"""
m = _re_actor_epoch.search(line)
- actor, epoch = m.groups()
- return (Actor._from_string(actor), int(epoch))
+ actor, epoch, offset = m.groups()
+ return (Actor._from_string(actor), int(epoch), -int(float(offset)/100*3600))