From 275b12c7e39a14a7be781b9e860e4b096f2fd987 Mon Sep 17 00:00:00 2001 From: Julien Bouyoud Date: Wed, 8 Feb 2023 12:07:10 +0100 Subject: [PATCH] feat(protected-branch): silently ignore ref not found when deleting --- plugins/protected-branch/src/index.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/plugins/protected-branch/src/index.ts b/plugins/protected-branch/src/index.ts index e65305592..dcfb229fb 100644 --- a/plugins/protected-branch/src/index.ts +++ b/plugins/protected-branch/src/index.ts @@ -111,11 +111,18 @@ export default class ProtectedBranchPlugin implements IPlugin { auto.logger.log.info("Delete release branch 🗑️ "); - await auto.git.github.git.deleteRef({ - owner: auto.git.options.owner, - repo: auto.git.options.repo, - ref: `heads/${headBranch}`, - }); + try { + await auto.git.github.git.deleteRef({ + owner: auto.git.options.owner, + repo: auto.git.options.repo, + ref: `heads/${headBranch}`, + }); + } catch (e) { + // Silently ignore reference not found error since the ref might already be deleted + if (!e || e.status !== 422 || e.message !== "Reference does not exist") { + throw e; + } + } }); } }