Skip to content

Commit acb989c

Browse files
committed
fix(source-control): Forgejo keeps watching pull requests with large commits
1 parent 3f70c83 commit acb989c

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
@@ -301,7 +301,11 @@ export const make = Effect.gen(function* () {
301301
})),
302302
),
303303
page({ ...input, path: `${pullPath(input)}/reviews` }, ForgejoReview),
304-
page({ ...input, path: `${pullPath(input)}/commits` }, ForgejoCommit),
304+
// Without these, each commit lists its files and a big merge outgrows the output limit.
305+
page(
306+
{ ...input, path: `${pullPath(input)}/commits?files=false&verification=false` },
307+
ForgejoCommit,
308+
),
305309
page({ ...input, path: `${issuePath(input)}/reactions` }, ForgejoReaction),
306310
getViewer(input),
307311
],
@@ -399,7 +403,7 @@ export const make = Effect.gen(function* () {
399403
? yield* read(
400404
{
401405
...input,
402-
path: `${repoPath(input)}/git/commits/${encodeURIComponent(input.commit)}`,
406+
path: `${repoPath(input)}/git/commits/${encodeURIComponent(input.commit)}?files=false&verification=false`,
403407
},
404408
ForgejoCommit,
405409
)

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

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,59 @@ it.effect(
521521
},
522522
);
523523

524+
it.effect("reads Forgejo pull request commits without their file lists", () => {
525+
const paths: string[] = [];
526+
return Effect.gen(function* () {
527+
const provider = yield* ForgejoPullRequestProvider.make;
528+
const activity = yield* provider.getChangeRequestActivity({
529+
cwd: "/repo",
530+
repository: "maria/project",
531+
host: "forgejo.test",
532+
number: 30,
533+
});
534+
assert.deepStrictEqual(
535+
activity.commits.map((commit) => commit.oid),
536+
["abc"],
537+
);
538+
const commitReads = paths.filter((path) =>
539+
path.startsWith("repos/maria/project/pulls/30/commits"),
540+
);
541+
assert.isNotEmpty(commitReads);
542+
for (const path of commitReads) {
543+
const query = new URLSearchParams(path.split("?")[1]);
544+
assert.strictEqual(query.get("files"), "false");
545+
assert.strictEqual(query.get("verification"), "false");
546+
}
547+
}).pipe(
548+
Effect.provide(
549+
Layer.mock(ForgejoCli.ForgejoCli)({
550+
api: (input) => {
551+
paths.push(input.path);
552+
const [path, query] = input.path.split("?");
553+
const page = Number(new URLSearchParams(query).get("page") ?? "1");
554+
const body =
555+
path === "user"
556+
? { login: "maria" }
557+
: path === "repos/maria/project/pulls/30/commits" && page === 1
558+
? [
559+
{
560+
sha: "abc",
561+
author: null,
562+
commit: {
563+
message: "Reorganize folders",
564+
committer: { date: "2026-10-11T00:00:00Z" },
565+
},
566+
parents: [],
567+
},
568+
]
569+
: [];
570+
return encodeJsonEffect(body).pipe(Effect.orDie, Effect.map(processOutput));
571+
},
572+
}),
573+
),
574+
);
575+
});
576+
524577
it.effect("discovers Forgejo accounts and retains the server port", () =>
525578
Effect.gen(function* () {
526579
const auth = ForgejoSourceControlProvider.discovery.parseAuth(

0 commit comments

Comments
 (0)