Skip to content

Commit

Permalink
fix(gomod): support .git indicator on private ee gitlab
Browse files Browse the repository at this point in the history
  • Loading branch information
bastianccm committed Aug 10, 2022
1 parent 6f324e4 commit 2aff74a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<html>
<head>
<meta name="go-import" content="my.custom.domain/golang/subgroup git https://my.custom.domain/golang/subgroup.git" />
<meta name="go-source"
content="my.custom.domain/golang/subgroup https://my.custom.domain/golang/subgroup https://my.custom.domain/golang/subgroup/-/tree/master{/dir} https://my.custom.domain/golang/subgroup/-/blob/master{/dir}/{file}#L{line}" />
</head>

<body>go get https://my.custom.domain/golang/subgroup</body>

</html>
18 changes: 18 additions & 0 deletions lib/modules/datasource/go/base.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,24 @@ describe('modules/datasource/go/base', () => {
});
});

it('supports GitLab EE deps in private subgroup with vcs indicator', async () => {
hostRules.find.mockReturnValue({ token: 'some-token' });
httpMock
.scope('https://my.custom.domain')
.get('/golang/subgroup/myrepo.git/v2?go-get=1')
.reply(200, Fixtures.get('go-get-gitlab-ee-private-subgroup.html'));

const res = await BaseGoDatasource.getDatasource(
'my.custom.domain/golang/subgroup/myrepo.git/v2'
);

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

it('supports GitLab EE monorepo deps in subgroup', async () => {
hostRules.find.mockReturnValue({ token: 'some-token' });
httpMock
Expand Down
13 changes: 13 additions & 0 deletions lib/modules/datasource/go/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,19 @@ export class BaseGoDatasource {

const registryUrl = `${parsedUrl.protocol}//${parsedUrl.host}`;

if (goModule.includes('.git')) {
// .git indicates a concrete git repository, which can be different from metadata returned by gitlab
const directUrl = URL.parse(`https://${goModule}`);
return {
datasource: GitlabTagsDatasource.id,
registryUrl,
packageName: `${directUrl.pathname}`.substring(
1,
`${directUrl.pathname}`.indexOf('.git')
),
};
}

return {
datasource: GitlabTagsDatasource.id,
registryUrl,
Expand Down

0 comments on commit 2aff74a

Please sign in to comment.