Skip to content

Commit

Permalink
fix(go): Revert private module URL changes (#31055)
Browse files Browse the repository at this point in the history
  • Loading branch information
zharinov committed Aug 27, 2024
1 parent 85c1163 commit 6899eb0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/modules/datasource/go/base.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ describe('modules/datasource/go/base', () => {
});
});

it('supports Go submodules in GitLab repo', async () => {
// eslint-disable-next-line jest/no-disabled-tests
it.skip('supports Go submodules in GitLab repo', async () => {
httpMock
.scope('https://gitlab.com')
.get('/example/module/submodule?go-get=1')
Expand Down Expand Up @@ -180,7 +181,7 @@ describe('modules/datasource/go/base', () => {

expect(res).toEqual({
datasource: GitlabTagsDatasource.id,
packageName: 'group/subgroup',
packageName: 'group/subgroup/my.git.module',
registryUrl: 'https://gitlab.com',
});
});
Expand Down
8 changes: 7 additions & 1 deletion lib/modules/datasource/go/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export class BaseGoDatasource {
private static readonly gitlabHttpsRegExp = regEx(
/^(?<httpsRegExpUrl>https:\/\/[^/]*gitlab\.[^/]*)\/(?<httpsRegExpName>.+?)(?:\/v\d+)?[/]?$/,
);
private static readonly gitlabRegExp = regEx(
/^(?<regExpUrl>gitlab\.[^/]*)\/(?<regExpPath>.+?)(?:\/v\d+)?[/]?$/,
);
private static readonly gitVcsRegexp = regEx(
/^(?:[^/]+)\/(?<module>.*)\.git(?:$|\/)/,
);
Expand Down Expand Up @@ -151,14 +154,17 @@ export class BaseGoDatasource {
};
}

const gitlabModuleName =
BaseGoDatasource.gitlabRegExp.exec(goModule)?.groups?.regExpPath;
const vcsIndicatedModule =
BaseGoDatasource.gitVcsRegexp.exec(goModule)?.groups?.module;

const metadataUrlMatchGroups =
BaseGoDatasource.gitlabHttpsRegExp.exec(metadataUrl)?.groups;
if (metadataUrlMatchGroups) {
const { httpsRegExpUrl, httpsRegExpName } = metadataUrlMatchGroups;
const packageName = vcsIndicatedModule ?? httpsRegExpName;
const packageName =
vcsIndicatedModule ?? gitlabModuleName ?? httpsRegExpName;
return {
datasource: GitlabTagsDatasource.id,
registryUrl: httpsRegExpUrl,
Expand Down

0 comments on commit 6899eb0

Please sign in to comment.