fix(github): try/catch getCommitStatus check

This commit is contained in:
Rhys Arkins 2019-04-25 18:18:18 +02:00
parent 4da4c13639
commit 34fbb7c5a7

View file

@ -476,7 +476,19 @@ async function getBranchStatus(branchName, requiredStatusChecks) {
const commitStatusUrl = `repos/${
config.repository
}/commits/${branchName}/status`;
const commitStatus = (await get(commitStatusUrl)).body;
let commitStatus;
try {
commitStatus = (await get(commitStatusUrl)).body;
} catch (err) /* istanbul ignore next */ {
if (err.statusCode === 404) {
logger.info(
'Received 404 when checking branch status, assuming that branch has been deleted'
);
throw new Error('repository-changed');
}
logger.info('Unknown error when checking branch status');
throw err;
}
logger.debug(
{ state: commitStatus.state, statuses: commitStatus.statuses },
'branch status check result'