Skip to content
Merged
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
9 changes: 8 additions & 1 deletion src/helpers/pullRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand All @@ -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(),
Expand Down