Skip to content
Open
Changes from all commits
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
17 changes: 13 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,16 @@ export class PullRequestHandler {
);
}

// Enqueue diff fetch on open, push, or merge
// Enqueue diff fetch on open, push, merge, or base retarget
const diffActions = ["opened", "synchronize", "closed"];
const isBaseRetarget = this.isBaseBranchRetargetEdit(action, payload);
const shouldFetchDiff =
diffActions.includes(action) && (action !== "closed" || pr.merged);
isBaseRetarget ||
(diffActions.includes(action) && (action !== "closed" || pr.merged));

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 Expand Up @@ -117,4 +119,11 @@ export class PullRequestHandler {
);
}
}

private isBaseBranchRetargetEdit(
action: string,
payload: Record<string, any>,
): boolean {
return action === "edited" && payload.changes?.base != null;
}
}