Skip to content
Snippets Groups Projects
Commit 2aa9c3c8 authored by Rhys Arkins's avatar Rhys Arkins
Browse files

fix: try/catch branch prune

parent ffc04a02
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,6 @@ module.exports = { ...@@ -3,7 +3,6 @@ module.exports = {
}; };
async function pruneStaleBranches(config, branchList) { async function pruneStaleBranches(config, branchList) {
// TODO: try/catch
logger.debug('Removing any stale branches'); logger.debug('Removing any stale branches');
logger.trace({ config }, `pruneStaleBranches`); logger.trace({ config }, `pruneStaleBranches`);
logger.debug(`config.repoIsOnboarded=${config.repoIsOnboarded}`); logger.debug(`config.repoIsOnboarded=${config.repoIsOnboarded}`);
...@@ -41,13 +40,17 @@ async function pruneStaleBranches(config, branchList) { ...@@ -41,13 +40,17 @@ async function pruneStaleBranches(config, branchList) {
return; return;
} }
for (const branchName of remainingBranches) { for (const branchName of remainingBranches) {
logger.info({ branch: branchName }, `Deleting orphan branch`); try {
const pr = await platform.findPr(branchName, null, 'open'); const pr = await platform.findPr(branchName, null, 'open');
if (pr) { if (pr) {
await platform.updatePr(pr.number, `${pr.title} - autoclosed`); await platform.updatePr(pr.number, `${pr.title} - autoclosed`);
logger.info({ prNo: pr.number, prTitle: pr.title }, 'PR autoclosed'); logger.info({ prNo: pr.number, prTitle: pr.title }, 'PR autoclosed');
}
const closePr = true;
await platform.deleteBranch(branchName, closePr);
logger.info({ branch: branchName }, `Deleting orphan branch`);
} catch (err) /* istanbul ignore next */ {
logger.warn({ err, branch: branchName }, 'Error pruning branch');
} }
const closePr = true;
await platform.deleteBranch(branchName, closePr);
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment