diff --git a/lib/workers/repository/error.spec.ts b/lib/workers/repository/error.spec.ts index 29008a48b71e1f14cb8e61a79d664a92b0f77132..c086208d058bca448f1444df1f3e02fbe59f1343 100644 --- a/lib/workers/repository/error.spec.ts +++ b/lib/workers/repository/error.spec.ts @@ -93,6 +93,13 @@ describe('workers/repository/error', () => { const res = await handleError(config, gitError); expect(res).toEqual(EXTERNAL_HOST_ERROR); }); + it('rewrites git fatal error', async () => { + const gitError = new Error( + 'fatal: not a git repository (or any parent up to mount point /mnt)\nStopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).\n' + ); + const res = await handleError(config, gitError); + expect(res).toEqual(REPOSITORY_TEMPORARY_ERROR); + }); it('handles unknown error', async () => { const res = await handleError(config, new Error('abcdefg')); expect(res).toEqual(UNKNOWN_ERROR); diff --git a/lib/workers/repository/error.ts b/lib/workers/repository/error.ts index f0a39befbd40a2fe50657f055f31aaa7ae42def2..b8f739c0ed1923aa5314e3cca0083bb3e2706719 100644 --- a/lib/workers/repository/error.ts +++ b/lib/workers/repository/error.ts @@ -183,6 +183,10 @@ export default async function handleError( // rewrite this error return EXTERNAL_HOST_ERROR; } + if (err.message.includes('fatal: not a git repository')) { + delete config.branchList; // eslint-disable-line no-param-reassign + return REPOSITORY_TEMPORARY_ERROR; + } // Swallow this error so that other repositories can be processed logger.error({ err }, `Repository has unknown error`); // delete branchList to avoid cleaning up branches