import type { RunTextCommand } from './exec.mts'; /** Thrown by {@link resolveHeadBranch} when `git branch --show-current` reports a detached HEAD. */ export declare class DetachedHeadError extends Error { constructor(); } /** Thrown by {@link assertHeadPushed} when the branch has no matching ref on the remote. */ export declare class HeadNotPushedError extends Error { constructor(branch: string, remote: string); } /** * Thrown by {@link assertHeadPushed} when `branch` exists on `remote` but at a different commit * than the local branch — creating the pull request now would silently use the stale remote tip. */ export declare class HeadOutOfDateError extends Error { constructor(branch: string, remote: string); } /** Resolves the current branch via `git branch --show-current`, trimmed. */ export declare function resolveHeadBranch(runGit: RunTextCommand): Promise; export type AssertHeadPushedOptions = { branch: string; remote?: string; }; /** * Confirms `branch` has a matching, up-to-date ref on `remote` (default `origin`) via * `git ls-remote --heads` and `git rev-parse`. Both use the full `refs/heads/` path * rather than the bare branch name: `ls-remote`'s pattern otherwise matches any ref whose name * ends with `branch` (not just an exact `refs/heads/`), and bare `rev-parse ` * resolves `refs/tags/` before `refs/heads/` when a same-named tag exists, either * of which could compare the wrong commit. `ls-remote --heads` exits `0` with empty stdout when * there is no match, so a missing branch is checked via stdout rather than the exit code. A * remote ref that exists but points at a different commit than the local branch means local HEAD * has commits the remote does not — that fails with {@link HeadOutOfDateError} rather than * silently creating the pull request from the stale remote tip. */ export declare function assertHeadPushed(runGit: RunTextCommand, { branch, remote }: AssertHeadPushedOptions): Promise; export type BuildGhPrCreateArgsOptions = { base?: string; bodyFile: string; draft?: boolean; head: string; labels?: readonly string[]; reviewers?: readonly string[]; title: string; }; /** Pure argv builder for `gh pr create`. `head` is always passed explicitly (never omitted). */ export declare function buildGhPrCreateArgs(options: BuildGhPrCreateArgsOptions): string[]; export type CreatePullRequestExecutors = { runGh: RunTextCommand; runGit: RunTextCommand; }; export type CreatePullRequestOptions = Omit & { head?: string; remote?: string; }; /** * Creates a pull request with `gh pr create --head `, resolving and verifying the head * branch first so the "must first push the current branch" non-interactive abort can never * happen — instead an unpushed branch fails fast with {@link HeadNotPushedError}. Returns the * trimmed PR URL that `gh pr create` prints to stdout. */ export declare function createPullRequest({ runGh, runGit }: CreatePullRequestExecutors, options: CreatePullRequestOptions): Promise;