From ae9c661c46fbaf825b5f4953e2e252437bb2281e Mon Sep 17 00:00:00 2001 From: Arav Jain Date: Mon, 16 Nov 2026 11:20:52 -0600 Subject: [PATCH 1/2] fix(shared): open Forgejo and Gitea /pulls/ tab and commit links Co-Authored-By: Claude Sonnet 5.5 --- packages/shared/src/pullRequestAnchor.test.ts | 5 +++++ packages/shared/src/pullRequestAnchor.ts | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/shared/src/pullRequestAnchor.test.ts b/packages/shared/src/pullRequestAnchor.test.ts index 6ea826924a992..e55940d851724 100644 --- a/packages/shared/src/pullRequestAnchor.test.ts +++ b/packages/shared/src/pullRequestAnchor.test.ts @@ -9,6 +9,7 @@ import { } from "./pullRequestAnchor.ts"; const gitlab = "https://gitlab.com/group/repo/-/merge_requests/7"; +const forgejo = "https://codeberg.org/owner/repo/pulls/7"; const url = "https://github.com/owner/repo/pull/7"; it.each(["discussion_r123", "r123", "discussion-diff-123R5-L9", "discussion-diff-123"])( @@ -107,6 +108,7 @@ it("handles encoded hashes and rejects invalid line numbers and URLs", () => { it("keeps the commit scope of a PR diff permalink", () => { const sha = "a".repeat(40); expect(pullRequestLinkCommit(`${url}/commits/${sha}#diff-abcR5`)).toBe(sha); + expect(pullRequestLinkCommit(`${forgejo}/commits/${sha}#diff-abcR5`)).toBe(sha); expect(pullRequestLinkCommit(`${url}/files#diff-abcR5`)).toBeNull(); expect(pullRequestLinkCommit(`${gitlab}/diffs?commit_id=${sha}#${"b".repeat(40)}`)).toBe(sha); expect(pullRequestLinkCommit(`${gitlab}/diffs?commit_id=main`)).toBeNull(); @@ -153,6 +155,9 @@ it.each([ [`${url}/commits/${"a".repeat(40)}`, "code"], [`${url}/commits`, "commits"], [`${url}/checks?check_run_id=1`, "checks"], + [`${forgejo}/files`, "code"], + [`${forgejo}/commits`, "commits"], + [`${forgejo}/commits/${"a".repeat(40)}`, "code"], [`${gitlab}/diffs`, "code"], [`${gitlab}/commits`, "commits"], [`${gitlab}/pipelines`, "checks"], diff --git a/packages/shared/src/pullRequestAnchor.ts b/packages/shared/src/pullRequestAnchor.ts index a16e7ced305a3..3e02f0f383424 100644 --- a/packages/shared/src/pullRequestAnchor.ts +++ b/packages/shared/src/pullRequestAnchor.ts @@ -39,9 +39,10 @@ function normalizePullRequestCommentAnchor(anchor: string): string { ); } -// GitHub pull request tabs and their GitLab merge request equivalents. +// GitHub pull request tabs and their GitLab merge request equivalents. Forgejo and Gitea spell the +// path `/pulls/`. function pullRequestPathTab(pathname: string): PullRequestAnchor | null { - const tab = /\/(?:pull|-\/merge_requests)\/\d+\/([a-z]+)(?:\/(.*))?$/i.exec(pathname); + const tab = /\/(?:pulls?|-\/merge_requests)\/\d+\/([a-z]+)(?:\/(.*))?$/i.exec(pathname); const rest = tab?.[2] ?? ""; switch (tab?.[1]?.toLowerCase()) { case "files": @@ -206,7 +207,7 @@ export function pullRequestLinkCommit(url: string | null | undefined): string | const { pathname, searchParams } = new URL(url); const commit = /\/-\/merge_requests\/\d+\/diffs\/?$/i.test(pathname) ? searchParams.get("commit_id") - : /\/pull\/\d+\/commits\/([a-f0-9]{40})\/?$/i.exec(pathname)?.[1]; + : /\/pulls?\/\d+\/commits\/([a-f0-9]{40})\/?$/i.exec(pathname)?.[1]; return commit && /^[a-f0-9]{40}$/i.test(commit) ? commit : null; } catch { return null; From d4f0c424f487cec2254a33445cc218e80adae5b5 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Mon, 16 Nov 2026 17:37:56 +0000 Subject: [PATCH 2/2] test(shared): keep one Forgejo tab case per parser Co-Authored-By: Claude Opus 5.5 --- packages/shared/src/pullRequestAnchor.test.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/shared/src/pullRequestAnchor.test.ts b/packages/shared/src/pullRequestAnchor.test.ts index e55940d851724..08bb25e75f477 100644 --- a/packages/shared/src/pullRequestAnchor.test.ts +++ b/packages/shared/src/pullRequestAnchor.test.ts @@ -156,8 +156,6 @@ it.each([ [`${url}/commits`, "commits"], [`${url}/checks?check_run_id=1`, "checks"], [`${forgejo}/files`, "code"], - [`${forgejo}/commits`, "commits"], - [`${forgejo}/commits/${"a".repeat(40)}`, "code"], [`${gitlab}/diffs`, "code"], [`${gitlab}/commits`, "commits"], [`${gitlab}/pipelines`, "checks"],