aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/api/v1.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/api/v1.js b/src/api/v1.js
index 743be09..25a8019 100644
--- a/src/api/v1.js
+++ b/src/api/v1.js
@@ -113,8 +113,18 @@ module.exports = function (fastify, opts, done)
path: "/tree",
handler: async (req, reply) =>
{
- const tree = await git.getTree(opts.config.settings.base_dir, req.params.repo);
+ const tree_path = (req.query.length !== 0 && req.query.path) ? req.query.path : null;
+ const tree = await git.getTree(opts.config.settings.base_dir, req.params.repo, tree_path);
+
+ if(tree.error) {
+ if(tree.error === 404) {
+ reply.code(404).send({ error: "Path not found" });
+ }
+ else {
+ reply.code(500).send({ error: "Internal server error" });
+ }
+ }
reply.send({ data: tree });
}
});