From 3562d00680886d3ac171218302280f0cf6ed8960 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Wed, 9 Aug 2023 19:30:47 +0200 Subject: [PATCH] fix: remove needs-manual label from original PR --- src/utils.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 18e021b..9b1b239 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -59,26 +59,30 @@ export const labelClosedPR = async ( `Labeling original PRs for PR at #${pr.number}`, ); + const targetLabel = PRStatus.TARGET + targetBranch; + if (change === PRChange.CLOSE) { - const targetLabel = PRStatus.TARGET + targetBranch; await labelUtils.removeLabel(context, pr.number, targetLabel); } const backportNumbers = getPRNumbersFromPRBody(pr); for (const prNumber of backportNumbers) { - const labelToRemove = PRStatus.IN_FLIGHT + targetBranch; + const inFlightLabel = PRStatus.IN_FLIGHT + targetBranch; + await labelUtils.removeLabel(context, prNumber, inFlightLabel); - // Add merged label to the original PR. If this is an intermediary PR, - // remove target labels from the current PR. if (change === PRChange.MERGE) { const mergedLabel = PRStatus.MERGED + targetBranch; - const targetLabel = PRStatus.TARGET + targetBranch; + const needsManualLabel = PRStatus.IN_FLIGHT + targetBranch; + // Add merged label to the original PR. await labelUtils.addLabels(context, prNumber, [mergedLabel]); + + // Remove the needs-manual-backport label from the original PR. + await labelUtils.removeLabel(context, prNumber, needsManualLabel); + + // Remove the target label from the intermediate PR. await labelUtils.removeLabel(context, pr.number, targetLabel); } - - await labelUtils.removeLabel(context, prNumber, labelToRemove); } };