@devries-cameron20 / t3code Mirror · read-only / commits / 71a283aed2
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 19:30 UTC

fix(server): Forgejo skipped jobs no longer keep a pull request watch pending (#16668)

Co-authored-by: Julius Marminge <51714798+juliusmarminge@users.noreply.github.com> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>

Igor Makowski committed Oct 23, 2026 at 07:41 UTC 71a283aed253f23be1860a31d4ea48f1c06e0b1c
2 files changed +82 -6
packages/source-control-forgejo/src/server/ForgejoSourceControlProvider.test.ts
+61
@@ -278,6 +278,67 @@ it.effect.each([
278 }).pipe(Effect.provide(requiredChecksLayer(Effect.fail(cause))));
279 });
280
281 +it.effect("reads Forgejo jobs that did not run as finished checks", () =>
282 + Effect.gen(function* () {
283 + const provider = yield* ForgejoPullRequestProvider.make;
284 + const read = provider.getChangeRequestChecks;
285 + if (read === undefined) return yield* Effect.die("checks read missing");
286 + const result = yield* read({
287 + cwd: "/repo",
288 + repository: "acme/web",
289 + host: "forgejo.test",
290 + number: 1,
291 + });
292 + assert.deepStrictEqual(
293 + result.checks.map((check) => [check.name, check.status]),
294 + [
295 + ["deploy", "skipped"],
296 + ["audit", "neutral"],
297 + ["docs", "pending"],
298 + ],
299 + );
300 + }).pipe(
301 + Effect.provide(
302 + Layer.mock(ForgejoCli.ForgejoCli)({
303 + api: (input) => {
304 + const status = (context: string, state: string) => ({
305 + context,
306 + status: state,
307 + description: null,
308 + target_url: null,
309 + updated_at: "2026-10-11T00:00:00Z",
310 + });
311 + const body = input.path.endsWith("pulls/1")
312 + ? {
313 + number: 1,
314 + title: "Checks",
315 + body: "",
316 + html_url: "https://forgejo.test/acme/web/pulls/1",
317 + user: null,
318 + state: "open",
319 + merged: false,
320 + head: { ref: "feature", sha: "head", repo: null },
321 + base: { ref: "main", sha: "base", repo: null },
322 + created_at: "2026-10-11T00:00:00Z",
323 + updated_at: "2026-10-11T00:00:00Z",
324 + closed_at: null,
325 + merged_at: null,
326 + labels: [],
327 + }
328 + : input.path.endsWith("page=1")
329 + ? [
330 + status("deploy", "skipped"),
331 + status("audit", "warning"),
332 + status("docs", "future-state"),
333 + ]
334 + : [];
335 + return encodeJsonEffect(body).pipe(Effect.orDie, Effect.map(processOutput));
336 + },
337 + }),
338 + ),
339 + ),
340 +);
341 +
342 it.effect("opens Forgejo Actions check links on the pull request's server", () =>
343 Effect.gen(function* () {
344 const provider = yield* ForgejoPullRequestProvider.make;
packages/source-control-forgejo/src/server/forgejoPullRequestJson.ts
+21 -6
@@ -4,6 +4,7 @@ import * as Option from "effect/Option";
4 import type {
5 PullRequestActor,
6 PullRequestCheck,
7 + PullRequestCheckStatus,
8 PullRequestComment,
9 PullRequestCommit,
10 PullRequestReaction,
@@ -213,6 +214,25 @@ export function forgejoCommit(commit: typeof ForgejoCommit.Type): PullRequestCom
214 };
215 }
216
217 +// Forgejo Actions reports a job that did not run as `skipped` and a cancelled one as `failure`,
218 +// and `warning` is finished without being a pass. Only `pending` and states we do not know may
219 +// hold a watch open.
220 +function forgejoCheckStatus(state: string): PullRequestCheckStatus {
221 + switch (state) {
222 + case "success":
223 + return "success";
224 + case "failure":
225 + case "error":
226 + return "failure";
227 + case "skipped":
228 + return "skipped";
229 + case "warning":
230 + return "neutral";
231 + default:
232 + return "pending";
233 + }
234 +}
235 +
236 export function forgejoChecks(
237 statuses: ReadonlyArray<typeof ForgejoStatus.Type>,
238 pullRequestUrl: string,
@@ -227,12 +247,7 @@ export function forgejoChecks(
247 url: status.target_url
248 ? (URL.parse(status.target_url, pullRequestUrl)?.href ?? null)
249 : null,
230 - status:
231 - status.status === "success"
232 - ? "success"
233 - : status.status === "failure" || status.status === "error"
234 - ? "failure"
235 - : "pending",
250 + status: forgejoCheckStatus(status.status),
251 },
252 })),
253 );