Skip to content

Commit

Permalink
fix(datasource/go): don't strip api/ from packageName on gitlab (#…
Browse files Browse the repository at this point in the history
…27635)

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
  • Loading branch information
ManuelB and viceice committed Feb 29, 2024
1 parent 88860db commit 158fa38
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
@@ -0,0 +1,12 @@
<html>

<head>
<meta name="go-import"
content="my.custom.domain/group/subgroup-api/myrepo git https://my.custom.domain/group/subgroup-api/myrepo.git" />
<meta name="go-source"
content="my.custom.domain/group/subgroup-api/myrepo https://my.custom.domain/group/subgroup-api/myrepo https://my.custom.domain/group/subgroup-api/myrepo/-/tree/master{/dir} https://my.custom.domain/group/subgroup-api/myrepo/-/blob/master{/dir}/{file}#L{line}" />
</head>

<body>go get https://my.custom.domain/group/subgroup-api/myrepo</body>

</html>
23 changes: 23 additions & 0 deletions lib/modules/datasource/go/base.spec.ts
Expand Up @@ -240,6 +240,29 @@ describe('modules/datasource/go/base', () => {
});
});

it('supports GitLab EE deps in private subgroup with api/ as part of packageName and api/v4 as part of endpoint', async () => {
GlobalConfig.set({ endpoint: 'https://my.custom.domain/api/v4' });

hostRules.hostType.mockReturnValue('gitlab');
httpMock
.scope('https://my.custom.domain')
.get('/group/subgroup-api/myrepo?go-get=1')
.reply(
200,
Fixtures.get('go-get-gitlab-ee-private-subgroup-api.html'),
);

const res = await BaseGoDatasource.getDatasource(
'my.custom.domain/group/subgroup-api/myrepo',
);

expect(res).toEqual({
datasource: GitlabTagsDatasource.id,
packageName: 'group/subgroup-api/myrepo',
registryUrl: 'https://my.custom.domain/',
});
});

it('supports GitLab EE deps in subgroup with version', async () => {
hostRules.hostType.mockReturnValue('gitlab');
httpMock
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/datasource/go/base.ts
Expand Up @@ -184,7 +184,7 @@ export class BaseGoDatasource {
endpoint,
);

if (endpointPrefix) {
if (endpointPrefix && endpointPrefix[1] !== 'api/') {
packageName = packageName.replace(endpointPrefix[1], '');
}

Expand Down

0 comments on commit 158fa38

Please sign in to comment.