diff --git a/lib/platform/gitlab/__snapshots__/index.spec.ts.snap b/lib/platform/gitlab/__snapshots__/index.spec.ts.snap index 5d4c684615dd18..2a334d52630101 100644 --- a/lib/platform/gitlab/__snapshots__/index.spec.ts.snap +++ b/lib/platform/gitlab/__snapshots__/index.spec.ts.snap @@ -2686,6 +2686,22 @@ Array [ ] `; +exports[`platform/gitlab/index initRepo should throw if ssh_url_to_repo is not present but gitUrl is set to ssh 1`] = ` +Array [ + Object { + "headers": Object { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "authorization": "Bearer abc123", + "host": "gitlab.com", + "user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)", + }, + "method": "GET", + "url": "https://gitlab.com/api/v4/projects/some%2Frepo%2Fproject", + }, +] +`; + exports[`platform/gitlab/index initRepo should fall back respecting when GITLAB_IGNORE_REPO_URL is set 1`] = ` Array [ Array [ diff --git a/lib/platform/gitlab/index.spec.ts b/lib/platform/gitlab/index.spec.ts index 9a27a2399a49b1..ba8effbea106bd 100644 --- a/lib/platform/gitlab/index.spec.ts +++ b/lib/platform/gitlab/index.spec.ts @@ -2,6 +2,7 @@ import { Platform, RepoParams } from '..'; import * as httpMock from '../../../test/http-mock'; import { + CONFIG_GIT_URL_UNAVAILABLE, REPOSITORY_ARCHIVED, REPOSITORY_CHANGED, REPOSITORY_DISABLED, @@ -302,6 +303,23 @@ describe('platform/gitlab/index', () => { expect(git.initRepo.mock.calls).toMatchSnapshot(); }); + it('should throw if ssh_url_to_repo is not present but gitUrl is set to ssh', async () => { + httpMock + .scope(gitlabApiHost) + .get('/api/v4/projects/some%2Frepo%2Fproject') + .reply(200, { + default_branch: 'master', + http_url_to_repo: `https://gitlab.com/some%2Frepo%2Fproject.git`, + }); + await expect( + gitlab.initRepo({ + repository: 'some/repo/project', + gitUrl: 'ssh', + }) + ).rejects.toThrow(CONFIG_GIT_URL_UNAVAILABLE); + expect(httpMock.getTrace()).toMatchSnapshot(); + }); + it('should fall back respecting when GITLAB_IGNORE_REPO_URL is set', async () => { process.env.GITLAB_IGNORE_REPO_URL = 'true'; const selfHostedUrl = 'http://mycompany.com/gitlab';