Skip to content

Commit 0d0c4d5

Browse files
committed
fix(gitlab): merge request links keep an HTTP remote's port and scheme
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent d01b92c commit 0d0c4d5

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

‎packages/source-control-gitlab/src/shared/definition.test.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,22 @@ describe("GitLab change request URLs", () => {
6161
number: 4,
6262
}),
6363
).toBe("https://gitlab.com/group/sub/project/-/merge_requests/4");
64+
expect(
65+
definition.changeRequestUrl({
66+
host: "gitlab.internal",
67+
repository: "team/app",
68+
number: 5,
69+
remoteUrl: "http://gitlab.internal:8080/team/app.git",
70+
}),
71+
).toBe("http://gitlab.internal:8080/team/app/-/merge_requests/5");
72+
expect(
73+
definition.changeRequestUrl({
74+
host: "gitlab.internal",
75+
repository: "team/app",
76+
number: 5,
77+
remoteUrl: "[email protected]:team/app.git",
78+
}),
79+
).toBe("https://gitlab.internal/team/app/-/merge_requests/5");
6480
expect(
6581
definition.changeRequestUrl({
6682
host: "gitlab.com",

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
parseChangeRequestPath,
99
parseCommitPath,
1010
projectChangeRequestHost,
11+
remoteWebOrigin,
1112
} from "@t3tools/source-control-core/shared/definition";
1213
import { icon } from "./icon.ts";
1314

@@ -38,10 +39,10 @@ export const definition = defineSourceControl({
3839
publishHost: () => "gitlab.com",
3940
newRepositoryOwner: (account) => ({ owner: account }),
4041
defaultCloneTransport: "ssh",
41-
changeRequestUrl: ({ host, repository, number, webUrl }) =>
42+
changeRequestUrl: ({ host, repository, number, remoteUrl, webUrl }) =>
4243
webUrl
4344
? changeRequestUrlBelow(webUrl, `-/merge_requests/${number}`)
44-
: `https://${host}/${repository}/-/merge_requests/${number}`,
45+
: `${remoteWebOrigin(host, remoteUrl)}/${repository}/-/merge_requests/${number}`,
4546
parseChangeRequestUrl: (url) => parseChangeRequestPath(url, CHANGE_REQUEST_PATH),
4647
commitUrl: (input) => buildCommitUrl(input, "-/commit"),
4748
parseCommitUrl: (url) => parseCommitPath(url, COMMIT_PATH),

0 commit comments

Comments
 (0)