Skip to content

Commit 500c3f9

Browse files
Copilottommoor
andauthored
Support GitLab work_items URL structure in unfurl integration (outline#11795)
* Initial plan * Support GitLab work_items URL structure in parseUrl Co-authored-by: tommoor <380914+tommoor@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tommoor <380914+tommoor@users.noreply.github.com>
1 parent f8098ab commit 500c3f9

2 files changed

Lines changed: 44 additions & 2 deletions

File tree

plugins/gitlab/shared/GitLabUtils.test.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,32 @@ describe("GitLabUtils.parseUrl", () => {
4242
});
4343
});
4444

45+
it("should parse a work_items URL", () => {
46+
const result = GitLabUtils.parseUrl(
47+
"https://gitlab.com/speak/purser/-/work_items/39"
48+
);
49+
expect(result).toEqual({
50+
owner: "speak",
51+
repo: "purser",
52+
type: UnfurlResourceType.Issue,
53+
id: 39,
54+
url: "https://gitlab.com/speak/purser/-/work_items/39",
55+
});
56+
});
57+
58+
it("should parse a nested group work_items URL", () => {
59+
const result = GitLabUtils.parseUrl(
60+
"https://gitlab.com/group/subgroup/repo/-/work_items/5"
61+
);
62+
expect(result).toEqual({
63+
owner: "group/subgroup",
64+
repo: "repo",
65+
type: UnfurlResourceType.Issue,
66+
id: 5,
67+
url: "https://gitlab.com/group/subgroup/repo/-/work_items/5",
68+
});
69+
});
70+
4571
it("should return undefined for unsupported resource type", () => {
4672
const result = GitLabUtils.parseUrl(
4773
"https://gitlab.com/speak/purser/-/pipelines/100"
@@ -182,6 +208,22 @@ describe("GitLabUtils.parseUrl", () => {
182208
});
183209
});
184210

211+
it("should parse a work_items URL with show parameter", () => {
212+
const show = btoa(
213+
JSON.stringify({ iid: "39", full_path: "speak/purser", id: 1215135 })
214+
);
215+
const result = GitLabUtils.parseUrl(
216+
`https://gitlab.com/speak/purser/-/work_items?show=${show}`
217+
);
218+
expect(result).toEqual({
219+
owner: "speak",
220+
repo: "purser",
221+
type: UnfurlResourceType.Issue,
222+
id: 39,
223+
url: `https://gitlab.com/speak/purser/-/work_items?show=${show}`,
224+
});
225+
});
226+
185227
it("should return undefined for invalid base64 in show parameter", () => {
186228
const result = GitLabUtils.parseUrl(
187229
"https://gitlab.com/speak/purser/-/issues?show=not-valid-base64!!!"

plugins/gitlab/shared/GitLabUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export class GitLabUtils {
142142
const owner = parts.join("/");
143143

144144
const type =
145-
resourceType === "issues"
145+
resourceType === "issues" || resourceType === "work_items"
146146
? UnfurlResourceType.Issue
147147
: resourceType === "merge_requests"
148148
? UnfurlResourceType.PR
@@ -192,7 +192,7 @@ export class GitLabUtils {
192192
const owner = parts.join("/");
193193

194194
const type =
195-
resourceType === "issues"
195+
resourceType === "issues" || resourceType === "work_items"
196196
? UnfurlResourceType.Issue
197197
: resourceType === "merge_requests"
198198
? UnfurlResourceType.PR

0 commit comments

Comments
 (0)