Skip to content

Commit a14ae43

Browse files
authored
Merge pull request #13292 from gitbutlerapp/warn-if-checks-blocked
Show "Blocked" when PR has missing required checks
2 parents 24c9896 + ae6e005 commit a14ae43

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

apps/desktop/src/components/branch/BranchCard.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@
270270
{projectId}
271271
branchName={pr.sourceBranch}
272272
prUpdatedAt={pr.updatedAt}
273+
mergeableState={pr.mergeableState}
273274
isFork={pr.fork}
274275
isMerged={pr.merged}
275276
/>

apps/desktop/src/components/forge/CIChecksBadge.svelte

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
projectId: string;
1212
branchName: string;
1313
prUpdatedAt?: string;
14+
mergeableState?: string;
1415
hasChecks?: boolean;
1516
isFork?: boolean;
1617
isMerged?: boolean;
@@ -29,6 +30,7 @@
2930
projectId,
3031
branchName,
3132
prUpdatedAt,
33+
mergeableState,
3234
isFork,
3335
isMerged,
3436
hasChecks = $bindable(),
@@ -83,6 +85,21 @@
8385
}
8486
8587
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+
86103
const style = checks.completed ? (checks.success ? "safe" : "danger") : "warning";
87104
// Keep the terminal icon stable during background re-fetches
88105
const icon = checks.completed ? (checks.success ? "tick" : "danger") : "spinner";
@@ -158,7 +175,13 @@
158175
prUpdatedAtChangedTime !== undefined &&
159176
Date.now() - prUpdatedAtChangedTime < STALE_GRACE_PERIOD_MS;
160177
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;
162185
163186
if (!isDone && loadedOnce && !loading && shouldStop) {
164187
projectState.branchesToPoll.remove(branchName);

0 commit comments

Comments
 (0)