|
11 | 11 | projectId: string; |
12 | 12 | branchName: string; |
13 | 13 | prUpdatedAt?: string; |
| 14 | + mergeableState?: string; |
14 | 15 | hasChecks?: boolean; |
15 | 16 | isFork?: boolean; |
16 | 17 | isMerged?: boolean; |
|
29 | 30 | projectId, |
30 | 31 | branchName, |
31 | 32 | prUpdatedAt, |
| 33 | + mergeableState, |
32 | 34 | isFork, |
33 | 35 | isMerged, |
34 | 36 | hasChecks = $bindable(), |
|
83 | 85 | } |
84 | 86 |
|
85 | 87 | if (checks) { |
| 88 | + // GitHub only returns check runs that have actually been created. |
| 89 | + // When required checks haven't reported yet, the API may return |
| 90 | + // all existing checks as passed while the PR is still unmergeable. |
| 91 | + if (checks.completed && checks.success) { |
| 92 | + if (mergeableState === "blocked") { |
| 93 | + return { |
| 94 | + style: "warning", |
| 95 | + icon: "warning", |
| 96 | + text: "Blocked", |
| 97 | + reducedText: "Blocked", |
| 98 | + tooltip: "Some required checks have not reported yet.", |
| 99 | + }; |
| 100 | + } |
| 101 | + } |
| 102 | +
|
86 | 103 | const style = checks.completed ? (checks.success ? "safe" : "danger") : "warning"; |
87 | 104 | // Keep the terminal icon stable during background re-fetches |
88 | 105 | const icon = checks.completed ? (checks.success ? "tick" : "danger") : "spinner"; |
|
158 | 175 | prUpdatedAtChangedTime !== undefined && |
159 | 176 | Date.now() - prUpdatedAtChangedTime < STALE_GRACE_PERIOD_MS; |
160 | 177 | const checksCompleted = checksQuery?.response?.completed || checksQuery?.response === null; |
161 | | - shouldStop = !withinGracePeriod && checksCompleted; |
| 178 | + // Don't stop polling if checks appear passed but the PR is blocked |
| 179 | + // (some required checks may not have been created yet). |
| 180 | + const blocked = |
| 181 | + checksQuery?.response?.completed && |
| 182 | + checksQuery?.response?.success && |
| 183 | + mergeableState === "blocked"; |
| 184 | + shouldStop = !withinGracePeriod && checksCompleted && !blocked; |
162 | 185 |
|
163 | 186 | if (!isDone && loadedOnce && !loading && shouldStop) { |
164 | 187 | projectState.branchesToPoll.remove(branchName); |
|
0 commit comments