Skip to content

Commit

Permalink
Add binary for blob.
Browse files Browse the repository at this point in the history
  • Loading branch information
xtao committed Oct 30, 2013
1 parent 9c13be8 commit f74110a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/blob.c
Original file line number Diff line number Diff line change
Expand Up @@ -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}
};
Expand Down
1 change: 1 addition & 0 deletions test/test_blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def test_read_blob(self):
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)
Expand Down

0 comments on commit f74110a

Please sign in to comment.