From bdc73fc19207488034d29d15826ad546714d46e0 Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Wed, 21 Nov 2018 23:18:06 +0100 Subject: [PATCH] fix(bitbucket): decline PR after deleting branch This fixes autoclose. Closes #2856 --- lib/platform/bitbucket/index.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/platform/bitbucket/index.js b/lib/platform/bitbucket/index.js index c6ff953058..b95bf10a6f 100644 --- a/lib/platform/bitbucket/index.js +++ b/lib/platform/bitbucket/index.js @@ -280,7 +280,19 @@ async function setBranchStatus( ); } -function deleteBranch(branchName) { +async function deleteBranch(branchName, closePr = false) { + // istanbul ignore if + if (closePr) { + logger.debug('Closing PR'); + const pr = await getBranchPr(branchName); + if (pr) { + await api.post( + `/2.0/repositories/${config.repository}/pullrequests/${ + pr.number + }/decline` + ); + } + } return api.delete( `/2.0/repositories/${config.repository}/refs/branches/${branchName}` ); -- GitLab