Skip to content

Commit 76c25c7

Browse files
fix(forgejo): reviewer picker lists each assignee once on Forgejo and Gitea (#23580)
Co-authored-by: maria-rcks <[email protected]>
1 parent 5b9c1ae commit 76c25c7

2 files changed

Lines changed: 46 additions & 3 deletions

File tree

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -603,12 +603,16 @@ export const make = Effect.gen(function* () {
603603
}),
604604
listReviewerCandidates: Effect.fn("ForgejoPullRequestProvider.listReviewerCandidates")(
605605
function* (input) {
606+
// Unpaginated in Forgejo: paging it returns the full list on every page.
606607
const [pr, users] = yield* Effect.all(
607-
[getPull(input), page({ ...input, path: `${repoPath(input)}/assignees` }, ForgejoUser)],
608+
[
609+
getPull(input),
610+
readArray({ ...input, path: `${repoPath(input)}/assignees` }, ForgejoUser),
611+
],
608612
{ concurrency: 2 },
609613
);
610614
return {
611-
candidates: users.items
615+
candidates: users
612616
.filter((user) => user.login !== pr.user?.login)
613617
.flatMap((user) => {
614618
const actor = forgejoActor(user);
@@ -625,7 +629,7 @@ export const make = Effect.gen(function* () {
625629
]
626630
: [];
627631
}),
628-
truncated: users.truncated,
632+
truncated: false,
629633
};
630634
},
631635
),

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,45 @@ it.effect(
985985
},
986986
);
987987

988+
it.effect("lists each Forgejo assignee once as a reviewer candidate", () => {
989+
const paths: string[] = [];
990+
return Effect.gen(function* () {
991+
const provider = yield* ForgejoPullRequestProvider.make;
992+
const result = yield* provider.listReviewerCandidates(requiredChecksInput);
993+
assert.deepStrictEqual(
994+
result.candidates.map((candidate) => [candidate.id, candidate.isRequested]),
995+
[
996+
["ana", true],
997+
["noor", false],
998+
],
999+
);
1000+
assert.strictEqual(result.truncated, false);
1001+
assert.strictEqual(paths.filter((path) => path.includes("/assignees")).length, 1);
1002+
}).pipe(
1003+
Effect.provide(
1004+
Layer.mock(ForgejoCli.ForgejoCli)({
1005+
api: (input) => {
1006+
paths.push(input.path);
1007+
const respond = (response: unknown) =>
1008+
encodeJsonEffect(response).pipe(Effect.orDie, Effect.map(processOutput));
1009+
switch (input.path.split("?")[0]) {
1010+
case "repos/acme/web/pulls/7":
1011+
return respond({
1012+
...requiredChecksPullRequest,
1013+
requested_reviewers: [{ login: "ana" }],
1014+
});
1015+
// Forgejo ignores paging here: every page is the full list, with no Link header.
1016+
case "repos/acme/web/assignees":
1017+
return respond([{ login: "maria" }, { login: "ana" }, { login: "noor" }]);
1018+
default:
1019+
return Effect.die(`Unexpected Forgejo request: ${input.path}`);
1020+
}
1021+
},
1022+
}),
1023+
),
1024+
);
1025+
});
1026+
9881027
it.effect("discovers Forgejo accounts and retains the server port", () =>
9891028
Effect.gen(function* () {
9901029
const auth = ForgejoSourceControlProvider.discovery.parseAuth(

0 commit comments

Comments
 (0)