From cf78a5b58bd35187641bd752b80719830fd76b29 Mon Sep 17 00:00:00 2001 From: Mattias Granlund Date: Thu, 4 Jul 2024 15:20:27 +0100 Subject: [PATCH] Work around bug in PR status after branch push - gh can incorrectly report checks as completed even though they just started - can be marked completed because not all checks are initially included in the check suite - for GitButler specifically somtimes check-runs includes only a single completed GitGuardian check --- app/src/lib/pr/PullRequestCard.svelte | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/lib/pr/PullRequestCard.svelte b/app/src/lib/pr/PullRequestCard.svelte index 294f10fe0..9da8f98bc 100644 --- a/app/src/lib/pr/PullRequestCard.svelte +++ b/app/src/lib/pr/PullRequestCard.svelte @@ -101,12 +101,18 @@ } function scheduleNextUpdate() { - if (!checksStatus || checksStatus.completed) return; + if (!checksStatus) return; const startedAt = checksStatus.startedAt; if (!startedAt) return; - const secondsAgo = (new Date().getTime() - startedAt.getTime()) / 1000; + const secondsAgo = (Date.now() - startedAt.getTime()) / 1000; + // Only stop polling for updates if checks have completed and check suite age is + // more than a minute. We do this to work around a bug where just after pushing + // to a branch GitHub might not report all the checks that will eventually be + // run as part of the suite. + if (checksStatus.completed && secondsAgo > 60) return; + let timeUntilUdate: number | undefined = undefined; if (secondsAgo < 60) { @@ -221,8 +227,7 @@ text: 'Your PR has conflicts that must be resolved before merging.' }; } - - if (mergeableState === 'blocked' && !isFetchingChecks) { + if (mergeableState === 'blocked' && !isFetchingChecks && checksStatus.failed > 0) { return { icon: 'error', messageStyle: 'error',