Skip to content

Commit 43fa031

Browse files
authored
fix: gitlab subgroups (#232)
Refs: #93 Signed-off-by: Victor Godoy <[email protected]>
1 parent e1f4045 commit 43fa031

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/remote.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ const getRemote = (remoteURL, options = {}) => {
2727

2828
const IS_BITBUCKET = /bitbucket/.test(hostname)
2929
const IS_GITLAB = /gitlab/.test(hostname)
30-
const IS_GITLAB_SUBGROUP = /\.git$/.test(remote.branch)
3130
const IS_AZURE = /dev\.azure/.test(hostname)
3231
const IS_VISUAL_STUDIO = /visualstudio/.test(hostname)
3332

@@ -43,9 +42,7 @@ const getRemote = (remoteURL, options = {}) => {
4342
}
4443

4544
if (IS_GITLAB) {
46-
const url = IS_GITLAB_SUBGROUP
47-
? `${protocol}//${hostname}/${remote.repo}/${remote.branch.replace(/\.git$/, '')}`
48-
: `${protocol}//${hostname}/${remote.repo}`
45+
const url = `${protocol}//${hostname}/${remote.pathname.replace(/git@.*:/, '').replace(/\.git$/, '')}`
4946
return {
5047
getCommitLink: id => `${url}/commit/${id}`,
5148
getIssueLink: id => `${url}/issues/${id}`,

test/remote.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,18 @@ const TEST_DATA = [
5555
compare: 'https://gitlab.com/user/repo/subgroup/compare/v1.2.3...v2.0.0'
5656
}
5757
},
58+
{
59+
remotes: [
60+
'https://gitlab.com/user/repo/group/repo.git',
61+
'[email protected]:user/repo/group/repo.git'
62+
],
63+
expected: {
64+
commit: 'https://gitlab.com/user/repo/group/repo/commit/123',
65+
issue: 'https://gitlab.com/user/repo/group/repo/issues/123',
66+
merge: 'https://gitlab.com/user/repo/group/repo/merge_requests/123',
67+
compare: 'https://gitlab.com/user/repo/group/repo/compare/v1.2.3...v2.0.0'
68+
}
69+
},
5870
{
5971
remotes: [
6072
'https://bitbucket.org/user/repo',

0 commit comments

Comments
 (0)