diff --git a/lib/platform/github/storage.js b/lib/platform/github/storage.js index cd491ebb4f33085acb23f54b3945696a4fafdaf9..ea0af7e914ea720c4c4a838803adb20ecfe9a9e3 100644 --- a/lib/platform/github/storage.js +++ b/lib/platform/github/storage.js @@ -348,10 +348,18 @@ class Storage { // Return the commit SHA for a branch async function getBranchCommit(branchName) { - const res = await get( - `repos/${config.repository}/git/refs/heads/${branchName}` - ); - return res.body.object.sha; + try { + const res = await get( + `repos/${config.repository}/git/refs/heads/${branchName}` + ); + return res.body.object.sha; + } catch (err) /* istanbul ignore next */ { + logger.debug({ err }, 'Error getting branch commit'); + if (err.statusCode === 404) { + throw new Error('repository-changed'); + } + throw err; + } } async function getCommitMessages() {