Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions packages/das/src/webhook/handlers/pull-request.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
Loading