Commit 53c6ae5e authored by Ivanq's avatar Ivanq

Repo: Take care of submodules in getTree()

parent e463a657
...@@ -178,32 +178,37 @@ class Repository { ...@@ -178,32 +178,37 @@ class Repository {
}); });
} }
getTree(tree, dir) { getTree(tree, dir) {
return this.git.readTreeItem(tree, dir) let submodules;
return this.git.getSubmodules(tree)
.then(s => {
submodules = s;
return this.git.readTreeItem(tree, dir);
})
.then(tree => { .then(tree => {
if(tree.type != "tree") { if(tree.type != "tree") {
return Promise.reject("Commit tree must be a tree"); return Promise.reject("Commit tree must be a tree");
} }
return Promise.all( tree.content.forEach(file => {
tree.content.map(file => { file.type = {
return this.git.readUnknownObject(file.id) blob: "file",
.then(object => { tree: "directory",
if(object.type == "blob") { submodule: "submodule"
file.type = "file"; }[file.type] || "unknown";
} else if(object.type == "tree") {
file.type = "directory"; if(file.type == "submodule") {
} else { let submodule = submodules.find(submodule => submodule.path == (dir ? dir + "/" + file.name : file.name));
file.type = "unknown"; if(submodule) {
} file.submodule = submodule;
} else {
return file; file.type = "error";
}) }
.catch(object => { }
file.type = "error"; });
return file;
}); return tree.content;
})
);
}); });
} }
getFile(branch, path) { getFile(branch, path) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment