FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Tree Entry getBlob() should also support the callback pattern. by jeffwilcox · Pull Request #405 · nodegit/nodegit · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .js  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
10 changes: 8 additions & 2 deletions lib/tree_entry.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,14 @@ TreeEntry.prototype.getTree = function(callback) {
* Retrieve the tree for this entry. Make sure to call `isTree` first!
* @return {Blob}
*/
TreeEntry.prototype.getBlob = function() {
return this.parent.repo.getBlob(this.oid());
TreeEntry.prototype.getBlob = function(callback) {
return this.parent.repo.getBlob(this.oid()).then(function(blob) {
if (typeof callback === "function") {
callback(null, blob);
}

return blob;
}, callback);
};

/**
Expand Down
9 changes: 9 additions & 0 deletions test/tests/tree_entry.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ describe("TreeEntry", function() {
});
});

it("provides the blob representation via callback", function() {
return this.commit.getEntry("test/raw-commit.js")
.then(function(entry) {
entry.getBlob(function (error, blob) {
assert.equal(blob.rawsize(), 2736);
});
});
});

it("provides the tree the entry is part of", function() {
return this.commit.getEntry("test")
.then(function(entry) {
Expand Down

Back | FazBrowse Home | New Git URL