| 199 | } |
| 200 | |
| 201 | function computeChecksStatus( |
| 202 | rollup: GHPRResponse["statusCheckRollup"], |
| 203 | ): NonNullable<GitHubStatus["pr"]>["checksStatus"] { |
| 204 | if (!rollup || rollup.length === 0) { |
| 205 | return "none"; |
| 206 | } |
| 207 | |
| 208 | let hasFailure = false; |
| 209 | let hasPending = false; |
| 210 | |
| 211 | for (const ctx of rollup) { |
| 212 | // StatusContext uses 'state', CheckRun uses 'conclusion' |
| 213 | const status = ctx.state || ctx.conclusion; |
| 214 | |
| 215 | if (status === "FAILURE" || status === "ERROR" || status === "TIMED_OUT") { |
| 216 | hasFailure = true; |
| 217 | } else if ( |
| 218 | status === "PENDING" || |
| 219 | status === "" || |
| 220 | status === null || |
| 221 | status === undefined |
| 222 | ) { |
| 223 | hasPending = true; |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | if (hasFailure) return "failure"; |
| 228 | if (hasPending) return "pending"; |
| 229 | return "success"; |
| 230 | } |