From 43ea66b738962c3faecd1e61bf43c480dc8840b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20David=20Ib=C3=A1=C3=B1ez?= <jdavid@itaapy.com> Date: Fri, 8 Apr 2011 17:03:41 +0200 Subject: [PATCH] Add support for the time offset of the signature --- pygit2.c | 9 ++++----- test/test_commit.py | 11 ++++++----- test/test_tag.py | 7 ++++--- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/pygit2.c b/pygit2.c index 8ad9d99..7c3f49e 100644 --- a/pygit2.c +++ b/pygit2.c @@ -556,21 +556,20 @@ static PyTypeObject ObjectType = { 0, /* tp_new */ }; -/* TODO Add support for the time offset */ static PyObject * build_person(const git_signature *signature) { - return Py_BuildValue("(ssL)", signature->name, signature->email, - signature->when.time); + return Py_BuildValue("(ssLi)", signature->name, signature->email, + signature->when.time, signature->when.offset); } static int signature_converter(PyObject *value, git_signature **out) { char *name, *email; long long time; - int offset = 0; + int offset; git_signature *signature; - if (!PyArg_ParseTuple(value, "ssL", &name, &email, &time)) + if (!PyArg_ParseTuple(value, "ssLi", &name, &email, &time, &offset)) return 0; signature = git_signature_new(name, email, time, offset); diff --git a/test/test_commit.py b/test/test_commit.py index 74a4220..6aea2a6 100644 --- a/test/test_commit.py +++ b/test/test_commit.py @@ -53,17 +53,18 @@ class CommitTest(utils.BareRepoTestCase): commit_time = 1288481576 self.assertEqual(commit_time, commit.commit_time) self.assertEqual( - ('Dave Borowitz', 'dborowitz@google.com', commit_time), + ('Dave Borowitz', 'dborowitz@google.com', commit_time, -420), commit.committer) - self.assertEqual(('Dave Borowitz', 'dborowitz@google.com', 1288477363), - commit.author) + self.assertEqual( + ('Dave Borowitz', 'dborowitz@google.com', 1288477363, -420), + commit.author) self.assertEqual( '967fce8df97cc71722d3c2a5930ef3e6f1d27b12', commit.tree.sha) def test_new_commit(self): message = 'New commit.\n\nMessage.\n' - committer = ('John Doe', 'jdoe@example.com', 12346) - author = ('Jane Doe', 'jdoe2@example.com', 12345) + committer = ('John Doe', 'jdoe@example.com', 12346, 0) + author = ('Jane Doe', 'jdoe2@example.com', 12345, 0) tree = '967fce8df97cc71722d3c2a5930ef3e6f1d27b12' parents = [COMMIT_SHA] diff --git a/test/test_tag.py b/test/test_tag.py index c3afdb7..f802b05 100644 --- a/test/test_tag.py +++ b/test/test_tag.py @@ -45,8 +45,9 @@ class TagTest(utils.BareRepoTestCase): self.assertEqual(pygit2.GIT_OBJ_TAG, tag.type) self.assertEqual(pygit2.GIT_OBJ_COMMIT, tag.target.type) self.assertEqual('root', tag.name) - self.assertEqual(('Dave Borowitz', 'dborowitz@google.com', 1288724692), - tag.tagger) + self.assertEqual( + ('Dave Borowitz', 'dborowitz@google.com', 1288724692, -420), + tag.tagger) self.assertEqual('Tagged root commit.\n', tag.message) commit = tag.target @@ -57,7 +58,7 @@ class TagTest(utils.BareRepoTestCase): name = 'thetag' target = 'af431f20fc541ed6d5afede3e2dc7160f6f01f16' message = 'Tag a blob.\n' - tagger = ('John Doe', 'jdoe@example.com', 12347) + tagger = ('John Doe', 'jdoe@example.com', 12347, 0) tag = pygit2.Tag(self.repo, name, target, pygit2.GIT_OBJ_BLOB, tagger, message)