Skip to content

Commit 332e86d

Browse files
authored
Merge pull request nodegit#1272 from rcjsuen/toObject
Expose a proper JavaScript API for TreeEntry's `toObject`
2 parents 7abe47f + ce2f4e3 commit 332e86d

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

generate/input/descriptor.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2590,6 +2590,17 @@
25902590
"return": {
25912591
"ownedByThis": true
25922592
}
2593+
},
2594+
"git_tree_entry_to_object": {
2595+
"args": {
2596+
"object_out": {
2597+
"isReturn": true
2598+
}
2599+
},
2600+
"return": {
2601+
"isErrorCode": true
2602+
},
2603+
"isAsync": true
25932604
}
25942605
}
25952606
},

test/tests/tree_entry.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,28 @@ describe("TreeEntry", function() {
156156
});
157157
});
158158

159+
it("can convert entry into a blob", function() {
160+
var repo = this.repository;
161+
return this.commit.getEntry("README.md")
162+
.then(function(entry) {
163+
return entry.toObject(repo);
164+
})
165+
.then(function(object) {
166+
assert.equal(object.isBlob(), true);
167+
});
168+
});
169+
170+
it("can convert entry into a tree", function() {
171+
var repo = this.repository;
172+
return this.commit.getEntry("example")
173+
.then(function(entry) {
174+
return entry.toObject(repo);
175+
})
176+
.then(function(object) {
177+
assert.equal(object.isTree(), true);
178+
});
179+
});
180+
159181
it("does not leak", function() {
160182
var test = this;
161183

0 commit comments

Comments
 (0)