Skip to content

Commit 4de78cd

Browse files
authored
fix(source-control): fix watch failures on large forgejo PRs (pingdotgg#18432)
1 parent 3adac94 commit 4de78cd

2 files changed

Lines changed: 59 additions & 2 deletions

File tree

‎packages/source-control-forgejo/src/server/ForgejoPullRequestProvider.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,11 @@ export const make = Effect.gen(function* () {
305305
})),
306306
),
307307
page({ ...input, path: `${pullPath(input)}/reviews` }, ForgejoReview),
308-
page({ ...input, path: `${pullPath(input)}/commits` }, ForgejoCommit),
308+
// Without these, each commit lists its files and a big merge outgrows the output limit.
309+
page(
310+
{ ...input, path: `${pullPath(input)}/commits?files=false&verification=false` },
311+
ForgejoCommit,
312+
),
309313
page({ ...input, path: `${issuePath(input)}/reactions` }, ForgejoReaction),
310314
getViewer(input),
311315
],
@@ -403,7 +407,7 @@ export const make = Effect.gen(function* () {
403407
? yield* read(
404408
{
405409
...input,
406-
path: `${repoPath(input)}/git/commits/${encodeURIComponent(input.commit)}`,
410+
path: `${repoPath(input)}/git/commits/${encodeURIComponent(input.commit)}?files=false&verification=false`,
407411
},
408412
ForgejoCommit,
409413
)

‎packages/source-control-forgejo/src/server/ForgejoSourceControlProvider.test.ts‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,59 @@ it.effect(
580580
},
581581
);
582582

583+
it.effect("reads Forgejo pull request commits without their file lists", () => {
584+
const paths: string[] = [];
585+
return Effect.gen(function* () {
586+
const provider = yield* ForgejoPullRequestProvider.make;
587+
const activity = yield* provider.getChangeRequestActivity({
588+
cwd: "/repo",
589+
repository: "maria/project",
590+
host: "forgejo.test",
591+
number: 30,
592+
});
593+
assert.deepStrictEqual(
594+
activity.commits.map((commit) => commit.oid),
595+
["abc"],
596+
);
597+
const commitReads = paths.filter((path) =>
598+
path.startsWith("repos/maria/project/pulls/30/commits"),
599+
);
600+
assert.isNotEmpty(commitReads);
601+
for (const path of commitReads) {
602+
const query = new URLSearchParams(path.split("?")[1]);
603+
assert.strictEqual(query.get("files"), "false");
604+
assert.strictEqual(query.get("verification"), "false");
605+
}
606+
}).pipe(
607+
Effect.provide(
608+
Layer.mock(ForgejoCli.ForgejoCli)({
609+
api: (input) => {
610+
paths.push(input.path);
611+
const [path, query] = input.path.split("?");
612+
const page = Number(new URLSearchParams(query).get("page") ?? "1");
613+
const body =
614+
path === "user"
615+
? { login: "maria" }
616+
: path === "repos/maria/project/pulls/30/commits" && page === 1
617+
? [
618+
{
619+
sha: "abc",
620+
author: null,
621+
commit: {
622+
message: "Reorganize folders",
623+
committer: { date: "2026-10-11T00:00:00Z" },
624+
},
625+
parents: [],
626+
},
627+
]
628+
: [];
629+
return encodeJsonEffect(body).pipe(Effect.orDie, Effect.map(processOutput));
630+
},
631+
}),
632+
),
633+
);
634+
});
635+
583636
it.effect("discovers Forgejo accounts and retains the server port", () =>
584637
Effect.gen(function* () {
585638
const auth = ForgejoSourceControlProvider.discovery.parseAuth(

0 commit comments

Comments
 (0)