fix(github): preserve clawsweeper proof labels (#83781)

This commit is contained in:
Tak Hoffman
2026-05-18 17:10:35 -05:00
committed by GitHub
parent d124c5aa20
commit 9968db65db
2 changed files with 114 additions and 2 deletions

View File

@@ -794,13 +794,36 @@ async function addMissingLabels(github, context, core, issueNumber, labels, labe
core.info(`Added candidate labels to #${issueNumber}: ${missingLabels.join(", ")}`);
}
function shouldRemoveProofSufficientLabel(context, proofEvaluation, hasExactHeadClawSweeperProof) {
function isClawSweeperOwnedLabel(label) {
return label === "clawsweeper" || label.startsWith("clawsweeper:");
}
function isActiveClawSweeperWork(pullRequest, labelSet) {
const authorLogin = pullRequest.user?.login ?? "";
const headRef = pullRequest.head?.ref ?? "";
return (
/clawsweeper/i.test(authorLogin) ||
headRef.startsWith("clawsweeper/") ||
[...labelSet].some(isClawSweeperOwnedLabel)
);
}
function shouldRemoveProofSufficientLabel(
context,
pullRequest,
labelSet,
proofEvaluation,
hasExactHeadClawSweeperProof,
) {
if (hasExactHeadClawSweeperProof) {
return false;
}
if (proofEvaluation.status === "override") {
return false;
}
if (isActiveClawSweeperWork(pullRequest, labelSet)) {
return false;
}
if (!["edited", "synchronize"].includes(context.payload.action)) {
return false;
}
@@ -836,7 +859,13 @@ async function applyPullRequestCandidateLabels(github, context, core, pullReques
);
if (
labelSet.has(PROOF_SUFFICIENT_LABEL) &&
shouldRemoveProofSufficientLabel(context, proofEvaluation, hasExactHeadClawSweeperProof)
shouldRemoveProofSufficientLabel(
context,
pullRequest,
labelSet,
proofEvaluation,
hasExactHeadClawSweeperProof,
)
) {
staleProofLabels.push(PROOF_SUFFICIENT_LABEL);
}
@@ -927,6 +956,9 @@ async function removeLabels(github, context, issueNumber, labels, labelSet) {
if (!labelSet.has(label)) {
continue;
}
if (isClawSweeperOwnedLabel(label)) {
continue;
}
try {
await github.rest.issues.removeLabel({
owner: context.repo.owner,