File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed
Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -79,7 +79,8 @@ TreeEntry.prototype.getBlob = function(callback) {
7979 * @return {String }
8080 */
8181TreeEntry . prototype . path = function ( callback ) {
82- return path . join ( this . parent . path ( ) , this . dirtoparent , this . filename ( ) ) ;
82+ var dirtoparent = this . dirtoparent || "" ;
83+ return path . join ( this . parent . path ( ) , dirtoparent , this . filename ( ) ) ;
8384} ;
8485
8586/**
Original file line number Diff line number Diff line change 11var assert = require ( "assert" ) ;
2+ var Promise = require ( "nodegit-promise" ) ;
23var path = require ( "path" ) ;
34var 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 ) {
You can’t perform that action at this time.
0 commit comments