Skip to content

Commit

Permalink
fix: gitlab subgroups (#232)
Browse files Browse the repository at this point in the history
Refs: #93

Signed-off-by: Victor Godoy <[email protected]>
  • Loading branch information
vigohe authored Sep 11, 2024
1 parent e1f4045 commit 43fa031
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const getRemote = (remoteURL, options = {}) => {

const IS_BITBUCKET = /bitbucket/.test(hostname)
const IS_GITLAB = /gitlab/.test(hostname)
const IS_GITLAB_SUBGROUP = /\.git$/.test(remote.branch)
const IS_AZURE = /dev\.azure/.test(hostname)
const IS_VISUAL_STUDIO = /visualstudio/.test(hostname)

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

if (IS_GITLAB) {
const url = IS_GITLAB_SUBGROUP
? `${protocol}//${hostname}/${remote.repo}/${remote.branch.replace(/\.git$/, '')}`
: `${protocol}//${hostname}/${remote.repo}`
const url = `${protocol}//${hostname}/${remote.pathname.replace(/git@.*:/, '').replace(/\.git$/, '')}`
return {
getCommitLink: id => `${url}/commit/${id}`,
getIssueLink: id => `${url}/issues/${id}`,
Expand Down
12 changes: 12 additions & 0 deletions test/remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ const TEST_DATA = [
compare: 'https://gitlab.com/user/repo/subgroup/compare/v1.2.3...v2.0.0'
}
},
{
remotes: [
'https://gitlab.com/user/repo/group/repo.git',
'[email protected]:user/repo/group/repo.git'
],
expected: {
commit: 'https://gitlab.com/user/repo/group/repo/commit/123',
issue: 'https://gitlab.com/user/repo/group/repo/issues/123',
merge: 'https://gitlab.com/user/repo/group/repo/merge_requests/123',
compare: 'https://gitlab.com/user/repo/group/repo/compare/v1.2.3...v2.0.0'
}
},
{
remotes: [
'https://bitbucket.org/user/repo',
Expand Down

0 comments on commit 43fa031

Please sign in to comment.