From 7892a4394a7ef96ebc48aa92984b52c8c285b52e Mon Sep 17 00:00:00 2001 From: Tobias Wilken Date: Sun, 30 Nov 2025 12:24:11 +0100 Subject: [PATCH] fix: filter push events by PR branch to prevent timer reset When a PR was merged to master, the push event affected the merge timer calculation for all other open PRs. This happened because getDates() was fetching all repository events and using the most recent PushEvent regardless of which branch it targeted. Now the code filters push events to only include those where payload.ref matches the PR's head branch (refs/heads/), preventing merges to master or other branches from resetting unrelated PR timers. Closes #752 --- src/helpers/pullRequest.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/helpers/pullRequest.js b/src/helpers/pullRequest.js index 7a2c185..acaad96 100644 --- a/src/helpers/pullRequest.js +++ b/src/helpers/pullRequest.js @@ -35,7 +35,10 @@ async function getDates(githubClient, pull) { return Math.max(new Date(total), latestCommitDate); }, new Date('January 1, 1970 00:00:00 UTC')); - // Get push events + // Get push events - filter to only include pushes to this PR's branch + // The GitHub Events API returns all repo events, so we must filter by ref + // to avoid other branch pushes (like merges to master) affecting this PR's timer + const prBranchRef = `refs/heads/${pull.head.ref}`; const repoEvents = await githubClient.getBranchEvents( pull.head.repo.events_url ); @@ -44,6 +47,10 @@ async function getDates(githubClient, pull) { if (current.type !== 'PushEvent') { return new Date(total); } + // Only consider push events to this PR's branch + if (current.payload?.ref !== prBranchRef) { + return new Date(total); + } return new Date( Math.max( new Date(total).getTime(),