Skip to content

Commit 697ba01

Browse files
author
Tom Ruggles
committed
Fix issue nodegit#591 - error when calling path() on a TreeEntry that was obtained from Tree.entries().
1 parent a85825e commit 697ba01

3 files changed

Lines changed: 30 additions & 5 deletions

File tree

lib/tree_entry.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,6 @@ TreeEntry.prototype.getBlob = function(callback) {
7979
* @return {String}
8080
*/
8181
TreeEntry.prototype.path = function(callback) {
82-
console.log({
83-
path: this.parent.path(),
84-
dirtoparent: this.dirtoparent,
85-
filename: this.filename()});
8682
var dirtoparent = this.dirtoparent || "";
8783
return path.join(this.parent.path(), dirtoparent, this.filename());
8884
};

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@
7474
"nw-gyp": "^0.12.4",
7575
"pangyp": "^2.1.0",
7676
"request": "^2.55.0",
77-
"tar": "^2.1.0"
77+
"tar": "^2.1.0",
78+
"bluebird": "^2.9.26"
7879
},
7980
"binary": {
8081
"module_name": "nodegit",

test/tests/tree_entry.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var assert = require("assert");
2+
var promise = require("bluebird");
23
var path = require("path");
34
var local = path.join.bind(path, __dirname);
45

@@ -52,6 +53,33 @@ describe("TreeEntry", function() {
5253
});
5354
});
5455

56+
it("provides the full path when the entry came from a tree", function(done) {
57+
var testTree = function(tree, _dir) {
58+
var dir = _dir || "",
59+
testPromises = [];
60+
tree.entries().forEach(function(entry) {
61+
var currentPath = path.join(dir, entry.filename());
62+
if (entry.isTree()) {
63+
testPromises.push(
64+
entry.getTree().then(function (subtree) {
65+
return testTree(subtree, currentPath);
66+
})
67+
);
68+
} else {
69+
assert.equal(entry.path(), currentPath);
70+
}
71+
});
72+
73+
return promise.all(testPromises);
74+
};
75+
76+
return this.commit.getTree()
77+
.then(testTree)
78+
.done(function() {
79+
done();
80+
});
81+
});
82+
5583
it("provides the blob representation of the entry", function() {
5684
return this.commit.getEntry("test/raw-commit.js")
5785
.then(function(entry) {

0 commit comments

Comments
 (0)