Skip to content

Commit 9a6bc96

Browse files
only21milclaude
andcommitted
fix(gitlab): accept merge request URLs from self-hosted hosts
The GitLab reference pattern required "gitlab" in the hostname and https, so a pasted merge request URL from a host like code.example.com or an http-only internal instance parsed to null and the checkout dialog and branch picker ignored it. The /-/merge_requests/ path is already GitLab's own, so match it on any host, the way the Forgejo pattern does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent bd6940b commit 9a6bc96

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

‎packages/client-runtime/src/pullRequestLinkInput.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,13 @@ describe("parsePullRequestReference", () => {
116116
).toBe("https://acme.visualstudio.com/project/_git/t3code/pullrequest/42");
117117
});
118118

119+
it.each([
120+
"https://code.example.com/group/project/-/merge_requests/42",
121+
"http://git.internal/group/sub/project/-/merge_requests/7",
122+
])("accepts self-hosted GitLab merge request URL %s", (url) => {
123+
expect(parsePullRequestReference(url)).toBe(url);
124+
});
125+
119126
it("accepts gh pr checkout commands with raw numbers", () => {
120127
expect(parsePullRequestReference("gh pr checkout 42")).toBe("42");
121128
});

‎packages/source-control-gitlab/src/client/definition.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import {
77
} from "@t3tools/source-control-core/client/definition";
88

99
const CHECKOUT_COMMAND = /^glab\s+mr\s+checkout\s+(.+)$/i;
10-
const CHANGE_REQUEST_REFERENCE =
11-
/^https:\/\/[^/\s]*gitlab[^/\s]*\/.+\/-\/merge_requests\/(\d+)(?:[/?#].*)?$/i;
10+
const CHANGE_REQUEST_REFERENCE = /^https?:\/\/[^/\s]+\/.+\/-\/merge_requests\/(\d+)(?:[/?#].*)?$/i;
1211

1312
const KIND = SourceControlProviderKind.make("gitlab");
1413

0 commit comments

Comments
 (0)