Design 47 H1: the seat git answers a listing's missing directory not-found (H-A-232)
A directory of a trees listing's files the commit does not hold was thrown as a plain error and answered with the kind failed, so the indexer took it for a forge that failed, never ran its one-directory fallback (issue 1585), and published nothing of the repository. commitTrees throws DirectoryNotInTree for it, and the seat's failure answers it with the kind not-found, the error naming the directory. Builds: design 47 H H-A-232 (2), H-A-234; issue 1585
This commit is contained in:
@@ -50,8 +50,9 @@ async function serve(pages: any[]) {
|
||||
res.end(JSON.stringify(pages[page - 1] ?? { sha: COMMIT, tree: [], truncated: false, page, total_count: 0 }));
|
||||
});
|
||||
await new Promise<void>((r) => server.listen(0, r));
|
||||
const client = new GiteaClient(`http://127.0.0.1:${(server.address() as any).port}`, "t");
|
||||
return { client, server, asked };
|
||||
const url = `http://127.0.0.1:${(server.address() as any).port}`;
|
||||
const client = new GiteaClient(url, "t");
|
||||
return { client, server, asked, url };
|
||||
}
|
||||
|
||||
test("a commit's trees: the root and the tree of each directory holding a module.json", async () => {
|
||||
@@ -238,12 +239,19 @@ test("files: every blob under each asked directory, recursively, as its path rel
|
||||
});
|
||||
|
||||
test("a directory of files the commit lacks, or spelled badly, or a listing the forge cut, fails and answers nothing", async () => {
|
||||
const { client, server } = await serve([{ sha: COMMIT, url: "u", tree: LISTING, truncated: false, page: 1, total_count: LISTING.length }]);
|
||||
const { client, server, url } = await serve([{ sha: COMMIT, url: "u", tree: LISTING, truncated: false, page: 1, total_count: LISTING.length }]);
|
||||
try {
|
||||
await assert.rejects(client.commitTrees("novox", "hq", COMMIT, undefined, ["modules/a", "modules/gone"]), (err: Error) => {
|
||||
assert.match(err.message, /modules\/gone/);
|
||||
// The seat answers it with the kind not-found naming the directory (novox/hq design 47 H H-A-232), never failed: the
|
||||
// holder's own client and failure, as the module runs them.
|
||||
const { failure } = await import("../dist/seat.js");
|
||||
const { GiteaClient } = await import("../dist/client.js");
|
||||
await assert.rejects(new GiteaClient(url, "t").commitTrees("novox", "hq", COMMIT, undefined, ["modules/a", "modules/gone"]), (err: Error) => {
|
||||
const said = failure(err);
|
||||
assert.equal(said["error-kind"], "not-found", JSON.stringify(said));
|
||||
assert.match(said.error, /the directory modules\/gone is not in novox\/hq/);
|
||||
return true;
|
||||
});
|
||||
await assert.rejects(client.commitTrees("novox", "hq", COMMIT, undefined, ["modules/a", "modules/gone"]), /modules\/gone/);
|
||||
await assert.rejects(client.commitTrees("novox", "hq", COMMIT, undefined, ["README.md"]), /README\.md/, "a file is no directory");
|
||||
for (const bad of ["../x", "/abs", "a//b", "modules/a/", "."]) {
|
||||
await assert.rejects(client.commitTrees("novox", "hq", COMMIT, undefined, [bad]), /files/, bad);
|
||||
|
||||
Reference in New Issue
Block a user