Skip to content

Commit

Permalink
Add support for GitLab's new style routes (#267)
Browse files Browse the repository at this point in the history
  • Loading branch information
Reddine authored Sep 11, 2024
1 parent 43fa031 commit 8feafe8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ const getRemote = (remoteURL, options = {}) => {
if (IS_GITLAB) {
const url = `${protocol}//${hostname}/${remote.pathname.replace(/git@.*:/, '').replace(/\.git$/, '')}`
return {
getCommitLink: id => `${url}/commit/${id}`,
getIssueLink: id => `${url}/issues/${id}`,
getMergeLink: id => `${url}/merge_requests/${id}`,
getCompareLink: (from, to) => `${url}/compare/${from}...${to}`,
getCommitLink: id => `${url}/-/commit/${id}`,
getIssueLink: id => `${url}/-/issues/${id}`,
getMergeLink: id => `${url}/-/merge_requests/${id}`,
getCompareLink: (from, to) => `${url}/-/compare/${from}...${to}`,
...overrides
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/commits.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ describe('getMerge', () => {
expect(getMerge(EXAMPLE_COMMIT, message, remotes.gitlab)).to.deep.equal({
id: '15007',
message: 'Memoize GitLab logger to reduce open file descriptors',
href: 'https://gitlab.com/user/repo/merge_requests/15007',
href: 'https://gitlab.com/user/repo/-/merge_requests/15007',
author: 'Commit Author',
commit: EXAMPLE_COMMIT
})
Expand All @@ -237,7 +237,7 @@ describe('getMerge', () => {
expect(getMerge(EXAMPLE_COMMIT, message, remotes.gitlabSubgroup)).to.deep.equal({
id: '15007',
message: 'Memoize GitLab logger to reduce open file descriptors',
href: 'https://gitlab.com/user/repo/subgroup/merge_requests/15007',
href: 'https://gitlab.com/user/repo/subgroup/-/merge_requests/15007',
author: 'Commit Author',
commit: EXAMPLE_COMMIT
})
Expand Down
16 changes: 8 additions & 8 deletions test/remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ const TEST_DATA = [
'[email protected]:user/repo.git'
],
expected: {
commit: 'https://gitlab.com/user/repo/commit/123',
issue: 'https://gitlab.com/user/repo/issues/123',
merge: 'https://gitlab.com/user/repo/merge_requests/123',
compare: 'https://gitlab.com/user/repo/compare/v1.2.3...v2.0.0'
commit: 'https://gitlab.com/user/repo/-/commit/123',
issue: 'https://gitlab.com/user/repo/-/issues/123',
merge: 'https://gitlab.com/user/repo/-/merge_requests/123',
compare: 'https://gitlab.com/user/repo/-/compare/v1.2.3...v2.0.0'
}
},
{
Expand All @@ -49,10 +49,10 @@ const TEST_DATA = [
'[email protected]:user/repo/subgroup.git'
],
expected: {
commit: 'https://gitlab.com/user/repo/subgroup/commit/123',
issue: 'https://gitlab.com/user/repo/subgroup/issues/123',
merge: 'https://gitlab.com/user/repo/subgroup/merge_requests/123',
compare: 'https://gitlab.com/user/repo/subgroup/compare/v1.2.3...v2.0.0'
commit: 'https://gitlab.com/user/repo/subgroup/-/commit/123',
issue: 'https://gitlab.com/user/repo/subgroup/-/issues/123',
merge: 'https://gitlab.com/user/repo/subgroup/-/merge_requests/123',
compare: 'https://gitlab.com/user/repo/subgroup/-/compare/v1.2.3...v2.0.0'
}
},
{
Expand Down

0 comments on commit 8feafe8

Please sign in to comment.