Skip to content
Snippets Groups Projects
Commit 7de273aa authored by Rhys Arkins's avatar Rhys Arkins
Browse files

fix(git): gracefully handle not a git repository failure

parent 8fdbbb52
Branches
Tags 23.47.2
No related merge requests found
......@@ -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);
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment