diff --git a/lib/platform/gitlab/index.ts b/lib/platform/gitlab/index.ts index 6cff4f176abb36a34ac5e6f525c9bb36be1f4b92..34a4e331adb83979282481878f594a15f2bdabc3 100644 --- a/lib/platform/gitlab/index.ts +++ b/lib/platform/gitlab/index.ts @@ -95,6 +95,12 @@ export async function initRepo({ ); throw new Error('archived'); } + if (res.body.mirror) { + logger.info( + 'Repository is a mirror - throwing error to abort renovation' + ); + throw new Error('mirror'); + } if (res.body.default_branch === null) { throw new Error('empty'); } diff --git a/lib/workers/repository/error.js b/lib/workers/repository/error.js index 050bee863af914561e7980b94a8f753b02723f70..7df44da6675ea36117800d3d10e8c121c88b67a4 100644 --- a/lib/workers/repository/error.js +++ b/lib/workers/repository/error.js @@ -27,6 +27,11 @@ async function handleError(config, err) { delete config.branchList; // eslint-disable-line no-param-reassign return err.message; } + if (err.message === 'mirror') { + logger.info('Repository is a mirror - skipping'); + delete config.branchList; // eslint-disable-line no-param-reassign + return err.message; + } if (err.message === 'renamed') { logger.info('Repository has been renamed - skipping'); delete config.branchList; // eslint-disable-line no-param-reassign diff --git a/lib/workers/repository/result.js b/lib/workers/repository/result.js index 69b90b3b8420e9fdcade59a5de3edf6c54b56ff2..76a08c1a76b32a8afd0f90c91ecc890c114bec16 100644 --- a/lib/workers/repository/result.js +++ b/lib/workers/repository/result.js @@ -10,6 +10,7 @@ function processResult(config, res) { 'disabled', 'forbidden', 'fork', + 'mirror', 'no-package-files', 'renamed', 'uninitiated', diff --git a/test/platform/gitlab/index.spec.ts b/test/platform/gitlab/index.spec.ts index 928c6a614484e57cbdd6696b54c4e305c68bbfd0..8a04db76fa22f17afd81869b08ff6d2c278cefbd 100644 --- a/test/platform/gitlab/index.spec.ts +++ b/test/platform/gitlab/index.spec.ts @@ -158,6 +158,12 @@ describe('platform/gitlab', () => { gitlab.initRepo({ repository: 'some/repo', localDir: '' }) ).rejects.toThrow(Error('archived')); }); + it('should throw an error if repository is a mirror', async () => { + api.get.mockReturnValue({ body: { mirror: true } } as any); + await expect( + gitlab.initRepo({ repository: 'some/repo', localDir: '' }) + ).rejects.toThrow(Error('mirror')); + }); it('should throw an error if repository is empty', async () => { api.get.mockReturnValue({ body: { default_branch: null } } as any); await expect( diff --git a/test/workers/repository/error.spec.js b/test/workers/repository/error.spec.js index b0eff479f01a3c07f52076b6e2a5872e5cf88e50..9615dc505d40d856d57b4adaf02836bcbd2d7ed9 100644 --- a/test/workers/repository/error.spec.js +++ b/test/workers/repository/error.spec.js @@ -20,6 +20,7 @@ describe('workers/repository/error', () => { 'config-validation', 'registry-failure', 'archived', + 'mirror', 'renamed', 'blocked', 'not-found',