From e47766c0f4cc85b89acfc1418353cf81537c0bc2 Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Thu, 1 Mar 2018 21:17:41 +0100 Subject: [PATCH] fix: add try/catch to getAllRenovateBranches --- lib/platform/github/index.js | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/platform/github/index.js b/lib/platform/github/index.js index 0feb77f36d..b23555415c 100644 --- a/lib/platform/github/index.js +++ b/lib/platform/github/index.js @@ -328,18 +328,22 @@ async function branchExists(branchName) { async function getAllRenovateBranches(branchPrefix) { logger.trace('getAllRenovateBranches'); - const allBranches = (await get( - `repos/${config.repository}/git/refs/heads/${branchPrefix}`, - { - paginate: true, - } - )).body; - return allBranches.reduce((arr, branch) => { - if (branch.ref.indexOf(`refs/heads/${branchPrefix}`) === 0) { - arr.push(branch.ref.substring('refs/heads/'.length)); - } - return arr; - }, []); + try { + const allBranches = (await get( + `repos/${config.repository}/git/refs/heads/${branchPrefix}`, + { + paginate: true, + } + )).body; + return allBranches.reduce((arr, branch) => { + if (branch.ref.indexOf(`refs/heads/${branchPrefix}`) === 0) { + arr.push(branch.ref.substring('refs/heads/'.length)); + } + return arr; + }, []); + } catch (err) /* istanbul ignore next */ { + return []; + } } async function isBranchStale(branchName) { -- GitLab