Skip to content

Commit

Permalink
Fix project path with /- in GitLab MR URL
Browse files Browse the repository at this point in the history
fixes #1028
  • Loading branch information
pgoudreau committed Apr 3, 2020
1 parent 4e36b7c commit 4ab7345
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ x

<!-- Your comment below this -->

<!-- Your comment above this -->
- Fix project path with /- in GitLab MR URL [@pgoudreau]
<!-- Your comment above this -->

# 10.1.0

Expand Down
54 changes: 54 additions & 0 deletions source/platforms/_tests/_pull_request_parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,60 @@ describe("parsing urls", () => {
})
})
})

describe("with /-", () => {
describe(".com", () => {
it("handles PRs-", () => {
expect(pullRequestParser("https://gitlab.com/GROUP/PROJ/-/merge_requests/123")).toEqual({
pullRequestNumber: "123",
repo: "GROUP/PROJ",
platform: "GitLab",
})
})

it("handles PRs sub-pages-", () => {
expect(pullRequestParser("https://gitlab.com/GROUP/PROJ/-/merge_requests/123/commits")).toEqual({
pullRequestNumber: "123",
repo: "GROUP/PROJ",
platform: "GitLab",
})
})

it("handles sub-groups", () => {
expect(pullRequestParser("https://gitlab.com/GROUP/SUBGROUP/PROJ/-/merge_requests/123")).toEqual({
pullRequestNumber: "123",
repo: "GROUP/SUBGROUP/PROJ",
platform: "GitLab",
})
})
})

describe("CE/EE", () => {
it("handles PRs", () => {
expect(pullRequestParser("https://localdomain/GROUP/PROJ/-/merge_requests/123")).toEqual({
pullRequestNumber: "123",
repo: "GROUP/PROJ",
platform: "GitLab",
})
})

it("handles PRs sub-pages", () => {
expect(pullRequestParser("https://localdomain/GROUP/PROJ/-/merge_requests/123/commits")).toEqual({
pullRequestNumber: "123",
repo: "GROUP/PROJ",
platform: "GitLab",
})
})

it("handles sub-groups", () => {
expect(pullRequestParser("https://localdomain/GROUP/SUBGROUP/PROJ/-/merge_requests/123")).toEqual({
pullRequestNumber: "123",
repo: "GROUP/SUBGROUP/PROJ",
platform: "GitLab",
})
})
})
})
})

describe("Bitbucket Cloud", () => {
Expand Down
2 changes: 1 addition & 1 deletion source/platforms/pullRequestParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function pullRequestParser(address: string): PullRequestParts | null {
if (parts) {
return {
platform: GitLab.name,
repo: parts[1],
repo: parts[1].replace(/\/-$/, ""),
pullRequestNumber: parts[2],
}
}
Expand Down

0 comments on commit 4ab7345

Please sign in to comment.