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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/tree.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
var path = require("path");
var events = require("events");
var NodeGit = require("../");
var Diff = NodeGit.Diff;
Expand Down Expand Up @@ -61,14 +62,15 @@ Tree.prototype.entryByName = function(name) {
* Get an entry at a path. Unlike by name, this takes a fully
* qualified path, like `/foo/bar/baz.javascript`
*
* @param {String} path
* @param {String} filePath
* @return {TreeEntry}
*/
Tree.prototype.getEntry = function(path, callback) {
Tree.prototype.getEntry = function(filePath, callback) {
var tree = this;

return this.entryByPath(path).then(function(entry) {
return this.entryByPath(filePath).then(function(entry) {
entry.parent = tree;
entry.dirtoparent = path.dirname(filePath);

if (typeof callback === "function") {
callback(null, entry);
Expand Down
2 changes: 1 addition & 1 deletion lib/tree_entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ TreeEntry.prototype.getBlob = function(callback) {
* @return {String}
*/
TreeEntry.prototype.path = function(callback) {
return path.join(this.parent.path(), this.filename());
return path.join(this.parent.path(), this.dirtoparent, this.filename());
};

/**
Expand Down
7 changes: 7 additions & 0 deletions test/tests/tree_entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ describe("TreeEntry", function() {
});
});

it("provides the full path", function() {
return this.commit.getEntry("test/raw-commit.js")
.then(function(entry) {
assert.equal(entry.path(), "test/raw-commit.js");
});
});

it("provides the blob representation of the entry", function() {
return this.commit.getEntry("test/raw-commit.js")
.then(function(entry) {
Expand Down