diff --git a/lib/datasource/go/base.spec.ts b/lib/datasource/go/base.spec.ts index 97ae5519522ec4ada97ecc42535a9a3cce8fa618..cfec05559715edc2d0c27c0625f32a560e0b0659 100644 --- a/lib/datasource/go/base.spec.ts +++ b/lib/datasource/go/base.spec.ts @@ -166,6 +166,23 @@ describe('datasource/go/base', () => { }); }); + it('supports GitLab deps with version', async () => { + httpMock + .scope('https://gitlab.com') + .get('/group/subgroup/v2?go-get=1') + .reply(200, loadFixture('go-get-gitlab.html')); + + const res = await BaseGoDatasource.getDatasource( + 'gitlab.com/group/subgroup/v2' + ); + + expect(res).toEqual({ + datasource: GitlabTagsDatasource.id, + lookupName: 'group/subgroup', + registryUrl: 'https://gitlab.com', + }); + }); + it('supports GitLab EE deps', async () => { hostRules.find.mockReturnValue({ token: 'some-token' }); httpMock diff --git a/lib/datasource/go/base.ts b/lib/datasource/go/base.ts index c148aee9d8a7b0af3d2c7f4c966f0ba9181bbb31..3b84220bab5f59ed5c538f5a86d4f09df0e8bc76 100644 --- a/lib/datasource/go/base.ts +++ b/lib/datasource/go/base.ts @@ -13,10 +13,10 @@ import type { DataSource } from './types'; // TODO: figure out class hierarchy (#10532) export class BaseGoDatasource { private static readonly gitlabHttpsRegExp = regEx( - /^(?<httpsRegExpUrl>https:\/\/[^/]*gitlab\.[^/]*)\/(?<httpsRegExpName>.+?)[/]?$/ + /^(?<httpsRegExpUrl>https:\/\/[^/]*gitlab\.[^/]*)\/(?<httpsRegExpName>.+?)(?:\/v\d+)?[/]?$/ ); private static readonly gitlabRegExp = regEx( - /^(?<regExpUrl>gitlab\.[^/]*)\/(?<regExpPath>.+?)[/]?$/ + /^(?<regExpUrl>gitlab\.[^/]*)\/(?<regExpPath>.+?)(?:\/v\d+)?[/]?$/ ); private static readonly id = 'go'; @@ -89,7 +89,6 @@ export class BaseGoDatasource { ?.httpsRegExpName; const gitlabModuleName = BaseGoDatasource.gitlabRegExp.exec(goModule)?.groups?.regExpPath; - if (gitlabUrl && gitlabUrlName) { if (gitlabModuleName?.startsWith(gitlabUrlName)) { if (gitlabModuleName.includes('.git')) { @@ -108,6 +107,7 @@ export class BaseGoDatasource { lookupName: gitlabModuleName, }; } + return { datasource: GitlabTagsDatasource.id, registryUrl: gitlabUrl,