Skip to content

Commit 2ed6167

Browse files
committed
Tree Entry getBlob() should also support the callback pattern.
1 parent c4aa206 commit 2ed6167

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

lib/tree_entry.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,14 @@ TreeEntry.prototype.getTree = function(callback) {
6363
* Retrieve the tree for this entry. Make sure to call `isTree` first!
6464
* @return {Blob}
6565
*/
66-
TreeEntry.prototype.getBlob = function() {
67-
return this.parent.repo.getBlob(this.oid());
66+
TreeEntry.prototype.getBlob = function(callback) {
67+
return this.parent.repo.getBlob(this.oid()).then(function(blob) {
68+
if (typeof callback === "function") {
69+
callback(null, blob);
70+
}
71+
72+
return blob;
73+
}, callback);
6874
};
6975

7076
/**

test/tests/tree_entry.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ describe("TreeEntry", function() {
5454
});
5555
});
5656

57+
it("provides the blob representation via callback", function() {
58+
return this.commit.getEntry("test/raw-commit.js")
59+
.then(function(entry) {
60+
entry.getBlob(function (error, blob) {
61+
assert.equal(blob.rawsize(), 2736);
62+
});
63+
});
64+
});
65+
5766
it("provides the tree the entry is part of", function() {
5867
return this.commit.getEntry("test")
5968
.then(function(entry) {

0 commit comments

Comments
 (0)