fix(gitFs): gracefully handle git config failure

This commit is contained in:
Rhys Arkins 2019-03-16 07:55:39 +01:00
parent e8509cf9bc
commit d8614aa785
3 changed files with 15 additions and 5 deletions

View file

@ -115,10 +115,15 @@ class Storage {
} }
if (config.gitAuthor) { if (config.gitAuthor) {
try {
await git.raw(['config', 'user.name', config.gitAuthor.name]); await git.raw(['config', 'user.name', config.gitAuthor.name]);
await git.raw(['config', 'user.email', config.gitAuthor.address]); await git.raw(['config', 'user.email', config.gitAuthor.address]);
// not supported yet // not supported yet
await git.raw(['config', 'commit.gpgsign', 'false']); await git.raw(['config', 'commit.gpgsign', 'false']);
} catch (err) /* istanbul ignore next */ {
logger.debug({ err }, 'Error setting git config');
throw new Error('temporary-error');
}
} }
await determineBaseBranch(); await determineBaseBranch();

View file

@ -109,6 +109,11 @@ async function handleError(config, err) {
delete config.branchList; // eslint-disable-line no-param-reassign delete config.branchList; // eslint-disable-line no-param-reassign
return err.message; return err.message;
} }
if (err.message === 'temporary-error') {
logger.info('Temporary error - aborting');
delete config.branchList; // eslint-disable-line no-param-reassign
return err.message;
}
if (err.message === 'lockfile-error') { if (err.message === 'lockfile-error') {
delete config.branchList; // eslint-disable-line no-param-reassign delete config.branchList; // eslint-disable-line no-param-reassign
logger.info('Lock file error - aborting'); logger.info('Lock file error - aborting');
@ -119,6 +124,5 @@ async function handleError(config, err) {
logger.error({ err }, `Repository has unknown error`); logger.error({ err }, `Repository has unknown error`);
// delete branchList to avoid cleaning up branches // delete branchList to avoid cleaning up branches
delete config.branchList; // eslint-disable-line no-param-reassign delete config.branchList; // eslint-disable-line no-param-reassign
logger.info({ err, message: err.message }, 'Unknown error');
return 'unknown-error'; return 'unknown-error';
} }

View file

@ -33,6 +33,7 @@ describe('workers/repository/error', () => {
'cannot-fork', 'cannot-fork',
'integration-unauthorized', 'integration-unauthorized',
'authentication-error', 'authentication-error',
'temporary-error',
]; ];
errors.forEach(err => { errors.forEach(err => {
it(`errors ${err}`, async () => { it(`errors ${err}`, async () => {