Merge remote-tracking branch 'xtao/blob'

This commit is contained in:
J. David Ibáñez 2013-11-01 10:30:42 +01:00
commit ff7ed95f29
2 changed files with 13 additions and 0 deletions

@ -41,12 +41,24 @@ Blob_size__get__(Blob *self)
}
PyDoc_STRVAR(Blob_binary__doc__, "Binary.");
PyObject *
Blob_binary__get__(Blob *self)
{
if (git_blob_is_binary(self->blob))
Py_RETURN_TRUE;
Py_RETURN_FALSE;
}
PyDoc_STRVAR(Blob_data__doc__,
"The contents of the blob, a bytes string. This is the same as\n"
"Blob.read_raw()");
PyGetSetDef Blob_getseters[] = {
GETTER(Blob, size),
GETTER(Blob, binary),
{"data", (getter)Object_read_raw, NULL, Blob_data__doc__, NULL},
{NULL}
};

@ -53,6 +53,7 @@ class BlobTest(utils.RepoTestCase):
sha = blob.oid.hex
self.assertEqual(sha, BLOB_SHA)
self.assertTrue(isinstance(blob, pygit2.Blob))
self.assertFalse(blob.binary)
self.assertEqual(pygit2.GIT_OBJ_BLOB, blob.type)
self.assertEqual(BLOB_CONTENT, blob.data)
self.assertEqual(len(BLOB_CONTENT), blob.size)