import type { Logger } from "pino"; import type { ParsedDiffFile } from "../server/utils/diff-highlighter.js"; import { type GitHubPullRequestStatusFacts, type GitHubService, type PullRequestMergeable } from "../services/github-service.js"; interface CheckoutReadCacheOptions { force?: boolean; reason?: string; } interface PullRequestStatusLookupTarget { headRef: string; headRepositoryOwner?: string; } export declare function __resetPullRequestStatusCacheForTests(): void; export declare function __setPullRequestStatusCacheTtlForTests(ttlMs: number): void; export declare function __resetCheckoutShortstatCacheForTests(): void; export declare function __setCheckoutShortstatCacheTtlForTests(ttlMs: number): void; export interface BranchSuggestion { name: string; committerDate: number; hasLocal: boolean; hasRemote: boolean; } export declare function listBranchSuggestions(cwd: string, options?: { query?: string; limit?: number; }): Promise; export interface LocalBranchCheckoutResolution { kind: "local"; name: string; } export interface RemoteOnlyBranchCheckoutResolution { kind: "remote-only"; name: string; remoteRef: string; } export interface NotFoundBranchCheckoutResolution { kind: "not-found"; } export type BranchCheckoutResolution = LocalBranchCheckoutResolution | RemoteOnlyBranchCheckoutResolution | NotFoundBranchCheckoutResolution; export declare function resolveBranchCheckout(cwd: string, name: string): Promise; export type BranchCheckoutSource = "local" | "remote"; export interface CheckoutExistingBranchResult { source: BranchCheckoutSource; } export interface CheckoutResolvedBranchInput { cwd: string; resolution: BranchCheckoutResolution; requestedBranch?: string; } export declare function checkoutResolvedBranch(input: CheckoutResolvedBranchInput): Promise; export declare class NotGitRepoError extends Error { readonly cwd: string; readonly code = "NOT_GIT_REPO"; constructor(cwd: string); } export declare class MergeConflictError extends Error { readonly baseRef: string; readonly currentBranch: string; readonly conflictFiles: string[]; constructor(options: { baseRef: string; currentBranch: string; conflictFiles: string[]; }); } export declare class MergeFromBaseConflictError extends Error { readonly baseRef: string; readonly currentBranch: string; readonly conflictFiles: string[]; constructor(options: { baseRef: string; currentBranch: string; conflictFiles: string[]; }); } export interface AheadBehind { ahead: number; behind: number; } export interface CheckoutStatus { isGit: false; } export interface CheckoutStatusGitNonPaseo { isGit: true; repoRoot: string; mainRepoRoot: string | null; currentBranch: string | null; isDirty: boolean; baseRef: string | null; aheadBehind: AheadBehind | null; aheadOfOrigin: number | null; behindOfOrigin: number | null; hasRemote: boolean; remoteUrl: string | null; isPaseoOwnedWorktree: false; } export interface CheckoutStatusGitPaseo { isGit: true; repoRoot: string; mainRepoRoot: string; currentBranch: string | null; isDirty: boolean; baseRef: string; aheadBehind: AheadBehind | null; aheadOfOrigin: number | null; behindOfOrigin: number | null; hasRemote: boolean; remoteUrl: string | null; isPaseoOwnedWorktree: true; } export type CheckoutStatusGit = CheckoutStatusGitNonPaseo | CheckoutStatusGitPaseo; export type CheckoutStatusResult = CheckoutStatus | CheckoutStatusGit; export interface CheckoutDiffResult { diff: string; structured?: ParsedDiffFile[]; } export interface CheckoutDiffCompare { mode: "uncommitted" | "base"; baseRef?: string; ignoreWhitespace?: boolean; includeStructured?: boolean; } export interface MergeToBaseOptions { baseRef?: string; mode?: "merge" | "squash"; commitMessage?: string; } export interface MergeFromBaseOptions { baseRef?: string; requireCleanTarget?: boolean; } export interface CheckoutContext { paseoHome?: string; worktreesRoot?: string; logger?: Pick; facts?: CheckoutSnapshotFacts | null; } export type CheckoutSnapshotFacts = { isGit: false; } | { isGit: true; worktreeRoot: string; currentBranch: string | null; remoteUrl: string | null; absoluteGitDir: string | null; gitCommonDir: string | null; paseoWorktree: PaseoWorktreeForCwd; storedBaseRef: string | null; resolvedBaseRef: string | null; mainRepoRoot: string | null; comparisonBaseRef: string | null; branchRemoteName: string | null; branchMergeRef: string | null; pullRequestLookupTarget: PullRequestStatusLookupTarget | null; }; export declare function getCurrentBranch(cwd: string): Promise; export declare function getMainRepoRoot(cwd: string): Promise; export interface GitWorktreeEntry { path: string; branchRef?: string; isBare?: boolean; } /** Check whether a path is under Paseo's worktree root. */ export declare function isPaseoWorktreePath(p: string, options?: { paseoHome?: string; worktreesRoot?: string; }): boolean; /** True when `child` is strictly inside `parent` (handles both `/` and `\`). */ export declare function isDescendantPath(child: string, parent: string): boolean; export declare function parseWorktreeList(output: string): GitWorktreeEntry[]; export declare function localBranchExists(cwd: string, branchName: string): Promise; export declare function renameCurrentBranch(cwd: string, newName: string): Promise<{ previousBranch: string | null; currentBranch: string | null; }>; type PaseoWorktreeForCwd = { isPaseoOwnedWorktree: false; } | { isPaseoOwnedWorktree: true; worktreeRoot: string; }; export declare function getOriginRemoteUrl(cwd: string): Promise; export declare function hasOriginRemote(cwd: string): Promise; export declare function resolveAbsoluteGitDir(cwd: string): Promise; export declare function resolveRepositoryDefaultBranch(repoRoot: string): Promise; export declare function getCheckoutSnapshotFacts(cwd: string, context?: CheckoutContext): Promise; export declare function getCheckoutStatus(cwd: string, context?: CheckoutContext): Promise; export interface CheckoutShortstat { additions: number; deletions: number; } export declare function getCheckoutShortstat(cwd: string, context?: CheckoutContext, options?: CheckoutReadCacheOptions): Promise; export declare function getCachedCheckoutShortstat(cwd: string): CheckoutShortstat | null | undefined; export declare function warmCheckoutShortstatInBackground(cwd: string, context?: CheckoutContext, onComplete?: () => void): void; export declare function getCheckoutDiff(cwd: string, compare: CheckoutDiffCompare, context?: CheckoutContext): Promise; export declare function commitChanges(cwd: string, options: { message: string; addAll?: boolean; }): Promise; export declare function commitAll(cwd: string, message: string): Promise; export declare function mergeToBase(cwd: string, options?: MergeToBaseOptions, context?: CheckoutContext): Promise; export declare function mergeFromBase(cwd: string, options?: MergeFromBaseOptions, context?: CheckoutContext): Promise; export declare function pullCurrentBranch(cwd: string, github?: GitHubService): Promise; export declare function pushCurrentBranch(cwd: string, github?: GitHubService): Promise; export interface CreatePullRequestOptions { title: string; body?: string; base?: string; head?: string; draft?: boolean; } export interface PullRequestStatus { number?: number; repoOwner?: string; repoName?: string; url: string; title: string; state: string; baseRefName: string; headRefName: string; isMerged: boolean; isDraft?: boolean; mergeable?: PullRequestMergeable; checks?: PullRequestCheck[]; checksStatus?: ChecksStatus; reviewDecision?: ReviewDecision; github?: GitHubPullRequestStatusFacts; } export interface PullRequestStatusResult { status: PullRequestStatus | null; githubFeaturesEnabled: boolean; } export interface PullRequestCheck { name: string; status: "success" | "failure" | "pending" | "skipped" | "cancelled"; url: string | null; workflow?: string; duration?: string; } export type ChecksStatus = "none" | "pending" | "success" | "failure"; export type ReviewDecision = "approved" | "changes_requested" | "pending" | null; export declare function createPullRequest(cwd: string, options: CreatePullRequestOptions, github?: GitHubService, context?: CheckoutContext): Promise<{ url: string; number: number; }>; export declare function getPullRequestStatus(cwd: string, github?: GitHubService, options?: CheckoutReadCacheOptions, context?: CheckoutContext): Promise; export {}; //# sourceMappingURL=checkout-git.d.ts.map