From 3c565fd220517185d18f612f44214bc84e2e2fe8 Mon Sep 17 00:00:00 2001 From: Marvin Date: Mon, 28 Sep 2026 13:59:43 +0530 Subject: [PATCH] fix: read fresh PR state before policy assessment --- scripts/policy.cjs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/policy.cjs b/scripts/policy.cjs index 606dc8f..a7d049b 100644 --- a/scripts/policy.cjs +++ b/scripts/policy.cjs @@ -168,8 +168,13 @@ async function getIssueForms(github, context) { } async function moderatePullRequest({github, context, core}) { - const pullRequest = context.payload.pull_request; - if (!pullRequest || pullRequest.state !== 'open' || Date.parse(pullRequest.created_at) < ENFORCEMENT_START || isTrusted(pullRequest)) return; + const eventPullRequest = context.payload.pull_request; + if (!eventPullRequest) return; + const {data: pullRequest} = await github.rest.pulls.get({ + ...context.repo, + pull_number: eventPullRequest.number + }); + if (pullRequest.state !== 'open' || Date.parse(pullRequest.created_at) < ENFORCEMENT_START || isTrusted(pullRequest)) return; const closingIssues = await getClosingIssues(github, context, pullRequest.number); if (closingIssues.length > 0 && closingIssues.every(isHelpWanted)) return;