From 80069f285e792698288a3eab01f55f8a38fd85ad Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Thu, 5 Sep 2019 09:26:53 +0200 Subject: [PATCH] fix(github): handle 404 status check gracefully --- lib/platform/github/index.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/platform/github/index.ts b/lib/platform/github/index.ts index be95b54da7..f4ef149696 100644 --- a/lib/platform/github/index.ts +++ b/lib/platform/github/index.ts @@ -651,13 +651,21 @@ export async function getBranchStatusCheck( ) { const branchCommit = await config.storage.getBranchCommit(branchName); const url = `repos/${config.repository}/commits/${branchCommit}/statuses`; - const res = await api.get(url); - for (const check of res.body) { - if (check.context === context) { - return check.state; + try { + const res = await api.get(url); + for (const check of res.body) { + if (check.context === context) { + return check.state; + } } + return null; + } catch (err) /* istanbul ignore next */ { + if (err.statusCode === 404) { + logger.info('Commit not found when checking statuses'); + throw new Error('repository-changed'); + } + throw err; } - return null; } export async function setBranchStatus( -- GitLab