fix(cleanup): Add pr exists check

This commit is contained in:
Rhys Arkins 2017-07-18 07:48:24 +02:00
parent 4eb20e0e57
commit f6980b51f2

View file

@ -18,15 +18,15 @@ async function pruneStaleBranches(config, branchList) {
if (renovateBranches.indexOf('renovate/lock-file-maintenance') !== -1) { if (renovateBranches.indexOf('renovate/lock-file-maintenance') !== -1) {
logger.debug('Checking lock file branch'); logger.debug('Checking lock file branch');
const pr = await config.api.getBranchPr('renovate/lock-file-maintenance'); const pr = await config.api.getBranchPr('renovate/lock-file-maintenance');
if (pr.isClosed) { if (pr && pr.isClosed) {
logger.info( logger.info(
'Deleting lock file maintenance branch as PR has been closed' 'Deleting lock file maintenance branch as PR has been closed'
); );
await config.api.deleteBranch('renovate/lock-file-maintenance'); await config.api.deleteBranch('renovate/lock-file-maintenance');
} else if (pr.isUnmergeable) { } else if (pr && pr.isUnmergeable) {
logger.info('Deleting lock file maintenance branch as it is unmergeable'); logger.info('Deleting lock file maintenance branch as it is unmergeable');
await config.api.deleteBranch('renovate/lock-file-maintenance'); await config.api.deleteBranch('renovate/lock-file-maintenance');
} else if (pr.changed_files === 0) { } else if (pr && pr.changed_files === 0) {
logger.info( logger.info(
'Deleting lock file maintenance branch as it has no changed files' 'Deleting lock file maintenance branch as it has no changed files'
); );