Something went wrong. Try again.
Monorepo for Tangled tangled.org
Something went wrong. Try again.
1234567891011121314151617181920212223242526import { browser } from "$app/environment";import type { PipelineSummary } from "$lib/components/repo/types";
export type CommitStatuses = Record<string, PipelineSummary>;
// the server has no spindle session, resolve empty so the boundary doesn't hangconst none: Promise<CommitStatuses> = Promise.resolve({});
export const commitStatuses = ( spindle: string | undefined, ownerHandle: string, repoName: string, shas: string[]): Promise<CommitStatuses> | undefined => { // only repos with a spindle run CI if (!spindle || shas.length === 0) return undefined; if (!browser) return none;
const params = new URLSearchParams(); for (const sha of new Set(shas)) params.append("sha", sha); const path = `/${encodeURIComponent(ownerHandle)}/${encodeURIComponent(repoName)}/commit-statuses?${params}`; return fetch(path) .then((res) => (res.ok ? (res.json() as Promise<CommitStatuses>) : ({} as CommitStatuses))) .catch(() => ({}));};