From f830e3df487500f42305cb7f958d76afd84d850f Mon Sep 17 00:00:00 2001 From: jeffrey701 Date: Tue, 19 May 2026 12:19:12 -0400 Subject: [PATCH 1/2] fix(webhook): refresh PR files on pull_request.edited base retarget (#62) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The handler enqueues PR_FILES on opened / synchronize / merged-closed but not on pull_request.edited with a base-ref change. The PR row updates its baseSha, but the stored pr_files and scoringDataStored stay pinned to the old base — leaving scoring inputs stale. Detect a base retarget via payload.changes.base, clear scoringDataStored, and enqueue PR_FILES with the new base/head SHAs through the existing prFilesJobId path. Closes #62 --- .../src/webhook/handlers/pull-request.handler.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/das/src/webhook/handlers/pull-request.handler.ts b/packages/das/src/webhook/handlers/pull-request.handler.ts index 7213834..19d919c 100644 --- a/packages/das/src/webhook/handlers/pull-request.handler.ts +++ b/packages/das/src/webhook/handlers/pull-request.handler.ts @@ -82,14 +82,20 @@ export class PullRequestHandler { ); } - // Enqueue diff fetch on open, push, or merge + // Enqueue diff fetch on open, push, merge, or base-branch retarget. + // GitHub sends `pull_request.edited` with `changes.base` when the base ref + // changes; stored pr_files were resolved against the old base and need a + // fresh fetch even when head_sha is unchanged. const diffActions = ["opened", "synchronize", "closed"]; + const isBaseRetarget = + action === "edited" && payload.changes?.base != null; const shouldFetchDiff = - diffActions.includes(action) && (action !== "closed" || pr.merged); + (diffActions.includes(action) && (action !== "closed" || pr.merged)) || + isBaseRetarget; if (shouldFetchDiff) { - // Reset scoring flag on new pushes - if (action === "synchronize") { + // Reset scoring flag on new pushes or base retargets + if (action === "synchronize" || isBaseRetarget) { await this.prRepo.update( { repoFullName, prNumber }, { scoringDataStored: false }, From b0a917468c8d0ac7f7089e365268b922a60a0018 Mon Sep 17 00:00:00 2001 From: jeffrey701 Date: Wed, 20 May 2026 17:27:27 -0400 Subject: [PATCH 2/2] chore: prettier --write on pull-request.handler.ts (#62) The lint CI run failed Prettier formatting on f830e3d. Prettier wanted the isBaseRetarget assignment on a single line. Single-line fit, no behaviour change. --- packages/das/src/webhook/handlers/pull-request.handler.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/das/src/webhook/handlers/pull-request.handler.ts b/packages/das/src/webhook/handlers/pull-request.handler.ts index 19d919c..e988ff7 100644 --- a/packages/das/src/webhook/handlers/pull-request.handler.ts +++ b/packages/das/src/webhook/handlers/pull-request.handler.ts @@ -87,8 +87,7 @@ export class PullRequestHandler { // changes; stored pr_files were resolved against the old base and need a // fresh fetch even when head_sha is unchanged. const diffActions = ["opened", "synchronize", "closed"]; - const isBaseRetarget = - action === "edited" && payload.changes?.base != null; + const isBaseRetarget = action === "edited" && payload.changes?.base != null; const shouldFetchDiff = (diffActions.includes(action) && (action !== "closed" || pr.merged)) || isBaseRetarget;