// engine/github/ci-status.ts — Query CI/CD status for a branch or PR.
/**
 * Get CI status for a given ref (branch name or PR number as string).
 */
export async function getCIStatusForRef(client, ref) {
    const checks = await client.getCIStatus(ref);
    if (checks.length === 0) {
        return { checks, overall: 'none' };
    }
    if (checks.some((c) => c.conclusion === 'failure')) {
        return { checks, overall: 'failure' };
    }
    if (checks.every((c) => c.conclusion === 'success')) {
        return { checks, overall: 'success' };
    }
    return { checks, overall: 'pending' };
}
/**
 * Format CI check results as a human-readable summary.
 */
export function formatCIStatus(checks) {
    if (checks.length === 0) {
        return 'No CI checks found.';
    }
    const lines = checks.map((check) => {
        const icon = check.conclusion === 'success' ? '+' : check.conclusion === 'failure' ? 'x' : '-';
        const status = check.conclusion ?? check.status;
        return `[${icon}] ${check.name}: ${status}`;
    });
    return lines.join('\n');
}
//# sourceMappingURL=ci-status.js.map