Skip to content

Commit a9a06f3

Browse files
committed
fix(source-control): Forgejo Actions check details open from pull requests
1 parent 3f70c83 commit a9a06f3

3 files changed

Lines changed: 71 additions & 3 deletions

File tree

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,10 @@ export const make = Effect.gen(function* () {
251251
},
252252
ForgejoStatus,
253253
);
254-
return { state: forgejoChangeRequest(pr).state, checks: forgejoChecks(statuses.items) };
254+
return {
255+
state: forgejoChangeRequest(pr).state,
256+
checks: forgejoChecks(statuses.items, pr.html_url),
257+
};
255258
},
256259
),
257260
getChangeRequest: Effect.fn("ForgejoPullRequestProvider.getChangeRequest")(function* (input) {
@@ -274,7 +277,7 @@ export const make = Effect.gen(function* () {
274277
const actor = forgejoActor(user);
275278
return actor ? [actor] : [];
276279
}),
277-
checks: forgejoChecks(statuses.items),
280+
checks: forgejoChecks(statuses.items, pr.html_url),
278281
baseComparison: !pr.merge_base
279282
? "unknown"
280283
: pr.merge_base === pr.base.sha

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

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,68 @@ it.effect("reads Forgejo checks without repository or viewer requests", () => {
165165
);
166166
});
167167

168+
it.effect("opens Forgejo Actions check links on the pull request's server", () =>
169+
Effect.gen(function* () {
170+
const provider = yield* ForgejoPullRequestProvider.make;
171+
const read = provider.getChangeRequestChecks;
172+
if (read === undefined) return yield* Effect.die("checks read missing");
173+
const result = yield* read({
174+
cwd: "/repo",
175+
repository: "acme/web",
176+
host: "forgejo.test",
177+
number: 1,
178+
});
179+
assert.deepStrictEqual(
180+
result.checks.map((check) => [check.name, check.url]),
181+
[
182+
["actions", "https://forgejo.test/git/acme/web/actions/runs/7/jobs/2"],
183+
["external", "https://ci.example/build/9"],
184+
["none", null],
185+
],
186+
);
187+
}).pipe(
188+
Effect.provide(
189+
Layer.mock(ForgejoCli.ForgejoCli)({
190+
api: (input) => {
191+
const status = (context: string, target_url: string | null) => ({
192+
context,
193+
status: "success",
194+
description: null,
195+
target_url,
196+
updated_at: "2026-10-11T00:00:00Z",
197+
});
198+
const body = input.path.endsWith("pulls/1")
199+
? {
200+
number: 1,
201+
title: "Checks",
202+
body: "",
203+
html_url: "https://forgejo.test/git/acme/web/pulls/1",
204+
user: null,
205+
state: "open",
206+
merged: false,
207+
head: { ref: "feature", sha: "head", repo: null },
208+
base: { ref: "main", sha: "base", repo: null },
209+
created_at: "2026-10-11T00:00:00Z",
210+
updated_at: "2026-10-11T00:00:00Z",
211+
closed_at: null,
212+
merged_at: null,
213+
labels: [],
214+
}
215+
: input.path.endsWith("page=1")
216+
? [
217+
// Forgejo includes any sub-path mount in the relative links it reports.
218+
status("actions", "/git/acme/web/actions/runs/7/jobs/2"),
219+
status("external", "https://ci.example/build/9"),
220+
status("none", null),
221+
]
222+
: [];
223+
return encodeJsonEffect(body).pipe(Effect.orDie, Effect.map(processOutput));
224+
},
225+
}),
226+
),
227+
),
228+
);
229+
168230
it.effect.each([
169231
["Ready", false, true, false, "mergeable"],
170232
["Draft", true, false, true, "unknown"],

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ export function forgejoCommit(commit: typeof ForgejoCommit.Type): PullRequestCom
210210

211211
export function forgejoChecks(
212212
statuses: ReadonlyArray<typeof ForgejoStatus.Type>,
213+
pullRequestUrl: string,
213214
): ReadonlyArray<PullRequestCheck> {
214215
return dedupeChecks(
215216
statuses.map((status) => ({
@@ -218,7 +219,9 @@ export function forgejoChecks(
218219
check: {
219220
name: status.context || "check",
220221
description: status.description || null,
221-
url: status.target_url || null,
222+
url: status.target_url
223+
? (URL.parse(status.target_url, pullRequestUrl)?.href ?? null)
224+
: null,
222225
status:
223226
status.status === "success"
224227
? "success"

0 commit comments

Comments
 (0)