GeezerVison is showing github.com — fix(shared): Bitbucket pull request links open their diff and commits… · pingdotgg/t3code@539ad91
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: packages/shared/src/pullRequestAnchor.test.ts +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -10,6 +10,7 @@ import { |
10 | 10 |
|
11 | 11 | const gitlab = "https://gitlab.com/group/repo/-/merge_requests/7"; |
12 | 12 | const forgejo = "https://codeberg.org/owner/repo/pulls/7"; |
| 13 | +const bitbucket = "https://bitbucket.org/workspace/repo/pull-requests/7"; |
13 | 14 |
|
14 | 15 | const url = "https://github.com/owner/repo/pull/7"; |
15 | 16 | it.each(["discussion_r123", "r123", "discussion-diff-123R5-L9", "discussion-diff-123"])( |
@@ -156,6 +157,8 @@ it.each([ |
156 | 157 | [`${url}/commits`, "commits"], |
157 | 158 | [`${url}/checks?check_run_id=1`, "checks"], |
158 | 159 | [`${forgejo}/files`, "code"], |
| 160 | + [`${bitbucket}/diff`, "code"], |
| 161 | + [`${bitbucket}/commits`, "commits"], |
159 | 162 | [`${gitlab}/diffs`, "code"], |
160 | 163 | [`${gitlab}/commits`, "commits"], |
161 | 164 | [`${gitlab}/pipelines`, "checks"], |
|
Collapse file
Copy file name to clipboardExpand all lines: packages/shared/src/pullRequestAnchor.ts +5-2Lines changed: 5 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -40,14 +40,17 @@ function normalizePullRequestCommentAnchor(anchor: string): string { |
40 | 40 | } |
41 | 41 |
|
42 | 42 | // GitHub pull request tabs and their GitLab merge request equivalents. Forgejo and Gitea spell the |
43 | | -// path `/pulls/`. |
| 43 | +// path `/pulls/`; Bitbucket spells it `/pull-requests/` and its code tab `diff`. |
44 | 44 | function pullRequestPathTab(pathname: string): PullRequestAnchor | null { |
45 | | - const tab = /\/(?:pulls?|-\/merge_requests)\/\d+\/([a-z]+)(?:\/(.*))?$/i.exec(pathname); |
| 45 | + const tab = /\/(?:pulls?|pull-requests|-\/merge_requests)\/\d+\/([a-z]+)(?:\/(.*))?$/i.exec( |
| 46 | + pathname, |
| 47 | + ); |
46 | 48 | const rest = tab?.[2] ?? ""; |
47 | 49 | switch (tab?.[1]?.toLowerCase()) { |
48 | 50 | case "files": |
49 | 51 | case "changes": |
50 | 52 | case "diffs": |
| 53 | + case "diff": |
51 | 54 | return { kind: "code" }; |
52 | 55 | case "commits": |
53 | 56 | if (rest === "") return { kind: "commits" }; |
|