From 7ee871e391cd2d2057175d54767fc71e708e32eb Mon Sep 17 00:00:00 2001 From: HampusM Date: Sat, 3 Jul 2021 17:42:51 +0200 Subject: Entries in the tree endpoint data contains name and not path & tree endpoint queries without a path gives you the root type --- packages/server/src/api/v1/repo/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'packages/server/src/api') diff --git a/packages/server/src/api/v1/repo/index.ts b/packages/server/src/api/v1/repo/index.ts index c13e173..51413d6 100644 --- a/packages/server/src/api/v1/repo/index.ts +++ b/packages/server/src/api/v1/repo/index.ts @@ -4,6 +4,7 @@ import { Blob } from "../../../git/blob"; import { Repository } from "../../../git/repository"; import { Tag } from "../../../git/tag"; import { TreeEntry } from "../../../git/tree_entry"; +import { basename } from "path"; import branches from "./branches"; import log from "./log"; import { verifyRepoName } from "../../util"; @@ -32,7 +33,8 @@ function addHooks(fastify: FastifyInstance, opts: FastifyPluginOptions): void { async function treeEntryMap(entry: TreeEntry) { const latest_commit = await entry.latestCommit(); return { - path: entry.path, + name: basename(entry.path), + type: entry.type, latest_commit: { id: latest_commit.id, message: latest_commit.message, @@ -80,7 +82,7 @@ export default function(fastify: FastifyInstance, opts: FastifyPluginOptions, do return; } - reply.send({ data: await Promise.all(tree.entries().map(treeEntryMap)) }); + reply.send({ data: { type: "tree", content: await Promise.all(tree.entries().map(treeEntryMap)) } }); } }); -- cgit v1.2.3-18-g5258