Add support for the time offset of the signature
This commit is contained in:
parent
7947c5396c
commit
43ea66b738
9
pygit2.c
9
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);
|
||||
|
@ -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]
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user