From a85825ed2cfc3756b2023d1db2608d597744b52e Mon Sep 17 00:00:00 2001 From: Tom Ruggles Date: Thu, 28 May 2015 20:28:57 -0400 Subject: [PATCH 1/3] Sometimes dirtoparent is not defined. Parent.path() is though so it should still be ok. --- lib/tree_entry.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/tree_entry.js b/lib/tree_entry.js index 2e4f15484..92856d85b 100644 --- a/lib/tree_entry.js +++ b/lib/tree_entry.js @@ -79,7 +79,12 @@ TreeEntry.prototype.getBlob = function(callback) { * @return {String} */ TreeEntry.prototype.path = function(callback) { - return path.join(this.parent.path(), this.dirtoparent, this.filename()); + console.log({ + path: this.parent.path(), + dirtoparent: this.dirtoparent, + filename: this.filename()}); + var dirtoparent = this.dirtoparent || ""; + return path.join(this.parent.path(), dirtoparent, this.filename()); }; /** From 697ba01094db8ad67e3f476f3d8a505eebb76288 Mon Sep 17 00:00:00 2001 From: Tom Ruggles Date: Thu, 28 May 2015 21:48:08 -0400 Subject: [PATCH 2/3] Fix issue #591 - error when calling path() on a TreeEntry that was obtained from Tree.entries(). --- lib/tree_entry.js | 4 ---- package.json | 3 ++- test/tests/tree_entry.js | 28 ++++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/lib/tree_entry.js b/lib/tree_entry.js index 92856d85b..d4309098c 100644 --- a/lib/tree_entry.js +++ b/lib/tree_entry.js @@ -79,10 +79,6 @@ TreeEntry.prototype.getBlob = function(callback) { * @return {String} */ TreeEntry.prototype.path = function(callback) { - console.log({ - path: this.parent.path(), - dirtoparent: this.dirtoparent, - filename: this.filename()}); var dirtoparent = this.dirtoparent || ""; return path.join(this.parent.path(), dirtoparent, this.filename()); }; diff --git a/package.json b/package.json index fe176ea59..cc29f7428 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,8 @@ "nw-gyp": "^0.12.4", "pangyp": "^2.1.0", "request": "^2.55.0", - "tar": "^2.1.0" + "tar": "^2.1.0", + "bluebird": "^2.9.26" }, "binary": { "module_name": "nodegit", diff --git a/test/tests/tree_entry.js b/test/tests/tree_entry.js index bfc32417d..fdc4bb719 100644 --- a/test/tests/tree_entry.js +++ b/test/tests/tree_entry.js @@ -1,4 +1,5 @@ var assert = require("assert"); +var promise = require("bluebird"); var path = require("path"); var local = path.join.bind(path, __dirname); @@ -52,6 +53,33 @@ describe("TreeEntry", function() { }); }); + it("provides the full path when the entry came from a tree", function(done) { + var testTree = function(tree, _dir) { + var dir = _dir || "", + testPromises = []; + tree.entries().forEach(function(entry) { + var currentPath = path.join(dir, entry.filename()); + if (entry.isTree()) { + testPromises.push( + entry.getTree().then(function (subtree) { + return testTree(subtree, currentPath); + }) + ); + } else { + assert.equal(entry.path(), currentPath); + } + }); + + return promise.all(testPromises); + }; + + return this.commit.getTree() + .then(testTree) + .done(function() { + done(); + }); + }); + it("provides the blob representation of the entry", function() { return this.commit.getEntry("test/raw-commit.js") .then(function(entry) { From 2434c758678773e9c04ca1b54f5da751269ff422 Mon Sep 17 00:00:00 2001 From: Tom Ruggles Date: Thu, 28 May 2015 22:25:04 -0400 Subject: [PATCH 3/3] Remove bluebird. --- package.json | 3 +-- test/tests/tree_entry.js | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index cc29f7428..fe176ea59 100644 --- a/package.json +++ b/package.json @@ -74,8 +74,7 @@ "nw-gyp": "^0.12.4", "pangyp": "^2.1.0", "request": "^2.55.0", - "tar": "^2.1.0", - "bluebird": "^2.9.26" + "tar": "^2.1.0" }, "binary": { "module_name": "nodegit", diff --git a/test/tests/tree_entry.js b/test/tests/tree_entry.js index fdc4bb719..371b8e636 100644 --- a/test/tests/tree_entry.js +++ b/test/tests/tree_entry.js @@ -1,5 +1,5 @@ var assert = require("assert"); -var promise = require("bluebird"); +var Promise = require("nodegit-promise"); var path = require("path"); var local = path.join.bind(path, __dirname); @@ -70,7 +70,7 @@ describe("TreeEntry", function() { } }); - return promise.all(testPromises); + return Promise.all(testPromises); }; return this.commit.getTree()