Add support for the time offset of the signature

This commit is contained in:
J. David Ibáñez 2011-04-08 17:03:41 +02:00
parent 7947c5396c
commit 43ea66b738
3 changed files with 14 additions and 13 deletions

@ -556,21 +556,20 @@ static PyTypeObject ObjectType = {
0, /* tp_new */ 0, /* tp_new */
}; };
/* TODO Add support for the time offset */
static PyObject * static PyObject *
build_person(const git_signature *signature) { build_person(const git_signature *signature) {
return Py_BuildValue("(ssL)", signature->name, signature->email, return Py_BuildValue("(ssLi)", signature->name, signature->email,
signature->when.time); signature->when.time, signature->when.offset);
} }
static int static int
signature_converter(PyObject *value, git_signature **out) { signature_converter(PyObject *value, git_signature **out) {
char *name, *email; char *name, *email;
long long time; long long time;
int offset = 0; int offset;
git_signature *signature; git_signature *signature;
if (!PyArg_ParseTuple(value, "ssL", &name, &email, &time)) if (!PyArg_ParseTuple(value, "ssLi", &name, &email, &time, &offset))
return 0; return 0;
signature = git_signature_new(name, email, time, offset); signature = git_signature_new(name, email, time, offset);

@ -53,17 +53,18 @@ class CommitTest(utils.BareRepoTestCase):
commit_time = 1288481576 commit_time = 1288481576
self.assertEqual(commit_time, commit.commit_time) self.assertEqual(commit_time, commit.commit_time)
self.assertEqual( self.assertEqual(
('Dave Borowitz', 'dborowitz@google.com', commit_time), ('Dave Borowitz', 'dborowitz@google.com', commit_time, -420),
commit.committer) commit.committer)
self.assertEqual(('Dave Borowitz', 'dborowitz@google.com', 1288477363), self.assertEqual(
commit.author) ('Dave Borowitz', 'dborowitz@google.com', 1288477363, -420),
commit.author)
self.assertEqual( self.assertEqual(
'967fce8df97cc71722d3c2a5930ef3e6f1d27b12', commit.tree.sha) '967fce8df97cc71722d3c2a5930ef3e6f1d27b12', commit.tree.sha)
def test_new_commit(self): def test_new_commit(self):
message = 'New commit.\n\nMessage.\n' message = 'New commit.\n\nMessage.\n'
committer = ('John Doe', 'jdoe@example.com', 12346) committer = ('John Doe', 'jdoe@example.com', 12346, 0)
author = ('Jane Doe', 'jdoe2@example.com', 12345) author = ('Jane Doe', 'jdoe2@example.com', 12345, 0)
tree = '967fce8df97cc71722d3c2a5930ef3e6f1d27b12' tree = '967fce8df97cc71722d3c2a5930ef3e6f1d27b12'
parents = [COMMIT_SHA] parents = [COMMIT_SHA]

@ -45,8 +45,9 @@ class TagTest(utils.BareRepoTestCase):
self.assertEqual(pygit2.GIT_OBJ_TAG, tag.type) self.assertEqual(pygit2.GIT_OBJ_TAG, tag.type)
self.assertEqual(pygit2.GIT_OBJ_COMMIT, tag.target.type) self.assertEqual(pygit2.GIT_OBJ_COMMIT, tag.target.type)
self.assertEqual('root', tag.name) self.assertEqual('root', tag.name)
self.assertEqual(('Dave Borowitz', 'dborowitz@google.com', 1288724692), self.assertEqual(
tag.tagger) ('Dave Borowitz', 'dborowitz@google.com', 1288724692, -420),
tag.tagger)
self.assertEqual('Tagged root commit.\n', tag.message) self.assertEqual('Tagged root commit.\n', tag.message)
commit = tag.target commit = tag.target
@ -57,7 +58,7 @@ class TagTest(utils.BareRepoTestCase):
name = 'thetag' name = 'thetag'
target = 'af431f20fc541ed6d5afede3e2dc7160f6f01f16' target = 'af431f20fc541ed6d5afede3e2dc7160f6f01f16'
message = 'Tag a blob.\n' 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, tag = pygit2.Tag(self.repo, name, target, pygit2.GIT_OBJ_BLOB,
tagger, message) tagger, message)