Skip to content
TypeScript

fix(gitlab): author names link to GitLab profiles (#30418)

Antonyf7409b051d5d
diff --git a/packages/source-control-gitlab/src/shared/definition.test.ts b/packages/source-control-gitlab/src/shared/definition.test.ts
index f57c6274dee..9cd95fadfaf 100644
--- a/packages/source-control-gitlab/src/shared/definition.test.ts
+++ b/packages/source-control-gitlab/src/shared/definition.test.ts
@@ -86,6 +86,18 @@ describe("GitLab change request URLs", () => {
}),
).toBe("https://gitlab.com/group/sub/project/-/merge_requests/4");
});
+
+ it("links authors, bots included, to their profile on the repository's host", () => {
+ expect(definition.authorProfileUrl("TonybynMp4", "https://gitlab.com/group/sub/project")).toBe(
+ "https://gitlab.com/TonybynMp4",
+ );
+ expect(
+ definition.authorProfileUrl(
+ "project_278964_bot_89f97e2c",
+ "http://gitlab.internal:8080/team/app/-/merge_requests/5",
+ ),
+ ).toBe("http://gitlab.internal:8080/project_278964_bot_89f97e2c");
+ });
});
describe("GitLab remotes", () => {
diff --git a/packages/source-control-gitlab/src/shared/definition.ts b/packages/source-control-gitlab/src/shared/definition.ts
index 10972a3e772..0360cde8812 100644
--- a/packages/source-control-gitlab/src/shared/definition.ts
+++ b/packages/source-control-gitlab/src/shared/definition.ts
@@ -60,7 +60,9 @@ export const definition = defineSourceControl({
checkoutCommand: ({ number }) => `glab mr checkout ${number}`,
changeRequestCloseCommand: /\bglab\s+mr\s+(?:merge|close)\b/u,
changeRequestCreateCommand: /\bglab\s+mr\s+create\b/u,
- authorProfileUrl: () => null,
+ // Bot users, unlike GitHub's, have real profile pages.
+ authorProfileUrl: (login, repositoryUrl) =>
+ new URL(`/${encodeURIComponent(login)}`, repositoryUrl).toString(),
reviewSummaryRequired: () => false,
checkoutCommandArgument: (input) => CHECKOUT_COMMAND.exec(input)?.[1]?.trim() ?? null,
isChangeRequestReference: (url) => CHANGE_REQUEST_REFERENCE.test(url),