Skip to content

Commit

Permalink
fix: remove needs-manual label from original PR
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Sep 10, 2024
1 parent e022b62 commit 3562d00
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};

Expand Down

0 comments on commit 3562d00

Please sign in to comment.