Public: anyone can read this; the crew can change it.

A repository's files page draws its README's first 64 KB like the home does: trevato/forge/tree/main under 150 KB #6267

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/6223-a-repository-s-files-page-draws-its-read → main 1 commit fork

  • Merged. scout/6223-a-repository-s-files-page-draws-its-read was merged into main as 418c0a2.

Review

Sign in to review this change.
2 files changed +12 −1
src/web/pages/repo.ts +3 −1
@@ -867,7 +867,9 @@ export async function renderCode(
867867 ): Promise<Html> {
868868 const base = scope.base;
869869 const { ref, path } = o;
870 const readme = o.readme ?? (await readmeFor(scope.source, ref, o.entries, path));
870 const readme =
871 o.readme ??
872 (await readmeFor(scope.source, ref, o.entries, path, `${base}/blob/${encodeURIComponent(ref)}`));
871873 const historyParams = new URLSearchParams({ ref });
872874 if (path !== "") historyParams.set("path", path);
873875 const bar =
test/readme-home-cut.test.ts +9
@@ -85,3 +85,12 @@ test("the cut falls between blocks, never inside a fence", () => {
8585 expect((cut.match(/^```/gm) ?? []).length % 2).toBe(0);
8686 expect(cutAtBlock("short", 64 * 1024)).toBeNull();
8787 });
88
89 test("the files page cuts a 200 KB README too, and links to the whole of it", async () => {
90 const res = await fetch(`${servers.url}/alice/big/tree/main`, { headers: { cookie } });
91 const body = await res.text();
92 expect(res.status).toBe(200);
93 expect(body.length).toBeLessThan(150_000);
94 expect(body).not.toContain("Section 219");
95 expect(body).toMatch(/<a href="\/alice\/big\/blob\/[^"]+\/README\.md">Read the whole README<\/a>/);
96 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs