export async function getSyncCountsAgainstDefaultBranch(args) {
    const { gitService, leftRef } = args;
    const defaultBranch = await gitService.getDefaultBranch().catch(() => null);
    if (!defaultBranch) {
        return {
            ahead: 0,
            behind: 0,
            degraded: true,
            baseRefCandidates: [],
        };
    }
    const baseRef = `origin/${defaultBranch}`;
    const refs = await gitService.raw([
        "ls-remote",
        "--heads",
        "origin",
        `refs/heads/${defaultBranch}`,
    ]);
    const hasRemoteBranch = refs.includes(`refs/heads/${defaultBranch}`);
    if (!hasRemoteBranch) {
        return {
            ahead: 0,
            behind: 0,
            degraded: true,
            baseRefCandidates: [baseRef],
        };
    }
    await gitService.fetch("origin", defaultBranch);
    const counts = await gitService.revList(leftRef, baseRef);
    return { ...counts, baseRefUsed: baseRef };
}
//# sourceMappingURL=status-sync.js.map