| 1 | /** Branch health and deployed-code checks refer to different commits after a no-op deploy. */ |
| 2 | export function projectCheckSections(head: string | null | undefined, branch: string | null | undefined, deployed: string | null | undefined) { |
| 3 | const sections: { kind: "branch" | "production"; label: string; sha: string }[] = []; |
| 4 | if (head) sections.push({ kind: "branch", label: `Latest on ${branch ?? "default branch"}`, sha: head }); |
| 5 | if (deployed && deployed !== head) sections.push({ kind: "production", label: "Checks for deployed commit", sha: deployed }); |
| 6 | return sections; |
| 7 | } |
| 8 | |
| 9 | /** A retry of the same SHA is still a separate attempt, including when no deployment ID was returned. */ |
| 10 | export function hasSeparateAttempt( |
| 11 | currentId: string | null | undefined, |
| 12 | servingSha: string | null | undefined, |
| 13 | latest: { id: string; sha: string; state: string }, |
| 14 | ): boolean { |
| 15 | if (!servingSha) return false; |
| 16 | return currentId ? latest.id !== currentId : latest.sha !== servingSha || latest.state !== "success"; |
| 17 | } |