Skip to content
Snippets Groups Projects
Unverified Commit 4ba04b47 authored by Bastian's avatar Bastian Committed by GitHub
Browse files

fix(gomod): explicitly match Gitlab ID for gitlab enterprise servers (#17611)

parent 6609461c
No related merge requests found
import { Fixtures } from '../../../../test/fixtures'; import { Fixtures } from '../../../../test/fixtures';
import * as httpMock from '../../../../test/http-mock'; import * as httpMock from '../../../../test/http-mock';
import { mocked } from '../../../../test/util'; import { mocked } from '../../../../test/util';
import { PlatformId } from '../../../constants';
import * as _hostRules from '../../../util/host-rules'; import * as _hostRules from '../../../util/host-rules';
import { GithubTagsDatasource } from '../github-tags'; import { GithubTagsDatasource } from '../github-tags';
import { GitlabTagsDatasource } from '../gitlab-tags'; import { GitlabTagsDatasource } from '../gitlab-tags';
...@@ -202,7 +203,7 @@ describe('modules/datasource/go/base', () => { ...@@ -202,7 +203,7 @@ describe('modules/datasource/go/base', () => {
}); });
it('supports GitLab EE deps', async () => { it('supports GitLab EE deps', async () => {
hostRules.find.mockReturnValue({ token: 'some-token' }); hostRules.hostType.mockReturnValue(PlatformId.Gitlab);
httpMock httpMock
.scope('https://my.custom.domain') .scope('https://my.custom.domain')
.get('/golang/myrepo?go-get=1') .get('/golang/myrepo?go-get=1')
...@@ -220,7 +221,7 @@ describe('modules/datasource/go/base', () => { ...@@ -220,7 +221,7 @@ describe('modules/datasource/go/base', () => {
}); });
it('supports GitLab EE deps in subgroup', async () => { it('supports GitLab EE deps in subgroup', async () => {
hostRules.find.mockReturnValue({ token: 'some-token' }); hostRules.hostType.mockReturnValue(PlatformId.Gitlab);
httpMock httpMock
.scope('https://my.custom.domain') .scope('https://my.custom.domain')
.get('/golang/subgroup/myrepo?go-get=1') .get('/golang/subgroup/myrepo?go-get=1')
...@@ -238,7 +239,7 @@ describe('modules/datasource/go/base', () => { ...@@ -238,7 +239,7 @@ describe('modules/datasource/go/base', () => {
}); });
it('supports GitLab EE deps in subgroup with version', async () => { it('supports GitLab EE deps in subgroup with version', async () => {
hostRules.find.mockReturnValue({ token: 'some-token' }); hostRules.hostType.mockReturnValue(PlatformId.Gitlab);
httpMock httpMock
.scope('https://my.custom.domain') .scope('https://my.custom.domain')
.get('/golang/subgroup/myrepo/v2?go-get=1') .get('/golang/subgroup/myrepo/v2?go-get=1')
...@@ -256,7 +257,7 @@ describe('modules/datasource/go/base', () => { ...@@ -256,7 +257,7 @@ describe('modules/datasource/go/base', () => {
}); });
it('supports GitLab EE deps in private subgroup with vcs indicator', async () => { it('supports GitLab EE deps in private subgroup with vcs indicator', async () => {
hostRules.find.mockReturnValue({ token: 'some-token' }); hostRules.hostType.mockReturnValue(PlatformId.Gitlab);
httpMock httpMock
.scope('https://my.custom.domain') .scope('https://my.custom.domain')
.get('/golang/subgroup/myrepo.git/v2?go-get=1') .get('/golang/subgroup/myrepo.git/v2?go-get=1')
...@@ -274,7 +275,7 @@ describe('modules/datasource/go/base', () => { ...@@ -274,7 +275,7 @@ describe('modules/datasource/go/base', () => {
}); });
it('supports GitLab EE monorepo deps in subgroup', async () => { it('supports GitLab EE monorepo deps in subgroup', async () => {
hostRules.find.mockReturnValue({ token: 'some-token' }); hostRules.hostType.mockReturnValue(PlatformId.Gitlab);
httpMock httpMock
.scope('https://my.custom.domain') .scope('https://my.custom.domain')
.get('/golang/subgroup/myrepo/monorepo?go-get=1') .get('/golang/subgroup/myrepo/monorepo?go-get=1')
......
...@@ -137,11 +137,7 @@ export class BaseGoDatasource { ...@@ -137,11 +137,7 @@ export class BaseGoDatasource {
}; };
} }
const opts = hostRules.find({ if (hostRules.hostType({ url: goSourceUrl }) === PlatformId.Gitlab) {
hostType: PlatformId.Gitlab,
url: goSourceUrl,
});
if (opts.token) {
// get server base url from import url // get server base url from import url
const parsedUrl = URL.parse(goSourceUrl); const parsedUrl = URL.parse(goSourceUrl);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment