import { BranchStartPoint, PrimaryBranchDetection } from '../types/index.js'; /** * Branch Resolver * * Resolves the remote, the repository's primary branch, and the commit a new * worktree should fork from. * * Every method here treats the remote as the source of truth and the local * branch as a possibly-stale cache: `git fetch` only advances * `refs/remotes//*`, never `refs/heads/*`, so branching off a local * branch name forks from whatever commit that branch happened to be left at. */ export declare class BranchResolver { private readonly repoRoot; constructor(repoRoot: string); /** * Name of the remote to treat as authoritative. * Prefers `origin`, otherwise the first configured remote. */ getRemoteName(): string | null; /** * Update remote-tracking refs. Best effort: an offline machine or an * unreachable host must not block worktree creation. */ fetch(remote: string): { ok: boolean; error?: string; }; /** * Re-read the remote's HEAD and update the local cache. * * `git fetch` never updates `refs/remotes//HEAD`, so a repository * cloned before the remote renamed its default branch keeps pointing at the * retired branch forever. Called after a successful fetch, when the network * is known to be reachable. */ refreshRemoteHead(remote: string): string | null; /** * Determine the repository's primary branch. * * Probes in order of decreasing confidence, falling through on every * failure so that a repository without a remote still resolves to something * usable. */ detectPrimaryBranch(remote: string | null): PrimaryBranchDetection | null; /** * Resolve the commit a new branch should fork from. * * A base that exists on the remote always resolves to `/` so * the worktree starts at the remote tip rather than the local branch tip. */ resolveStartPoint(base: string, remote: string | null): BranchStartPoint; /** Local branches, for error messages. */ listLocalBranches(): string[]; /** Remote-tracking branches for `remote`, for error messages. */ listRemoteBranches(remote: string): string[]; localBranchExists(branch: string): boolean; remoteBranchExists(remote: string, branch: string): boolean; /** Resolve a start point to a short commit hash, for reporting. */ describeCommit(revision: string): string | null; /** * Ask the remote which branch its HEAD points at. * Requires network access; returns null when unavailable. */ private queryRemoteHead; /** * Persist the remote's HEAD locally so subsequent runs skip the network hop. * Purely an optimisation — failure is ignored. */ private cacheRemoteHead; private isValidCommittish; private stripRemotePrefix; private splitLines; private git; private gitSucceeds; } //# sourceMappingURL=BranchResolver.d.ts.map