From 43fa03108d02474db8d189f07ab8435c377a16d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Felipe=20Godoy=20Hern=C3=A1ndez?= Date: Wed, 11 Sep 2024 16:26:41 -0300 Subject: [PATCH] fix: gitlab subgroups (#232) Refs: #93 Signed-off-by: Victor Godoy --- src/remote.js | 5 +---- test/remote.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/remote.js b/src/remote.js index 667fd57a..94b48101 100644 --- a/src/remote.js +++ b/src/remote.js @@ -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) @@ -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}`, diff --git a/test/remote.js b/test/remote.js index 4a0209e6..5ab75c96 100644 --- a/test/remote.js +++ b/test/remote.js @@ -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', + 'git@gitlab.com: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',