import { SimpleGit } from 'simple-git';
import { ChangeRecord } from '../types/change-types';
export type RepoInfo = {
    owner: string;
    repo: string;
    provider: 'github';
    baseUrl: string;
    remoteUrl: string;
};
export type FileDiffStats = {
    file: string;
    insertions: number;
    deletions: number;
};
export type DiffStats = {
    files: FileDiffStats[];
    totalInsertions: number;
    totalDeletions: number;
};
export declare class LocalGitService {
    private cachedRootGit;
    private static repoMutexes;
    private static lockContext;
    private getMutex;
    private withLock;
    /**
     * Execute multiple git operations within a single lock context.
     * Useful for atomic operations or to reduce log spam from repeated acquisitions.
     */
    executeInLock<T>(projectPath: string, fn: () => Promise<T>): Promise<T>;
    private getGit;
    /** Resolves the git root for a project path. Caches the result since it never changes. */
    getGitRootPath(projectPath: string): Promise<SimpleGit | null>;
    configureDefaultIdentity(projectPath: string): Promise<void>;
    /** Checkout an existing local branch. */
    checkoutBranch(projectPath: string, branchName: string): Promise<string>;
    /** List all local branches sorted by most recently updated. */
    listBranches(projectPath: string): Promise<string[]>;
    /** Check whether a local branch with the given name already exists. */
    branchExists(projectPath: string, branchName: string): Promise<boolean>;
    createBranch(projectPath: string, branchName: string): Promise<string>;
    commitChange(projectPath: string, change: ChangeRecord, userInfo?: {
        name: string;
        email: string;
    }, commitMessage?: string): Promise<string>;
    /**
     * Stage all tracked changes and commit with a user-provided message.
     * Uses `git commit -a` to stage and commit in a single subprocess.
     */
    commitWithMessage(projectPath: string, message: string): Promise<string>;
    getCurrentBranch(projectPath: string): Promise<string>;
    /**
     * Detect the default branch on origin (e.g. origin/main or origin/master)
     * Returns the full remote ref like "origin/main"
     */
    getOriginDefaultBranch(projectPath: string): Promise<string>;
    getStatus(projectPath: string): Promise<{
        hasChanges: boolean;
        branch: string;
        files: string[];
    }>;
    hasUncommittedChanges(projectPath: string): Promise<boolean>;
    getRepositoryInfo(projectPath: string): Promise<RepoInfo>;
    private parseRepoUrl;
    pushBranch(projectPath: string, branchName: string): Promise<void>;
    generatePullRequestUrl(projectPath: string, branchName: string, defaultBranch?: string): Promise<string>;
    /** Get the diff of modified-but-not-staged files in the working tree. */
    getUnstagedDiff(projectPath: string): Promise<string>;
    /** Get all uncommitted changes (staged + unstaged) relative to HEAD. */
    getUncommittedDiff(projectPath: string): Promise<string>;
    /**
     * Get git diff between two branches
     * @param projectPath Path to the git repository
     * @param baseBranch Base branch to compare from (e.g., 'main')
     * @param compareBranch Branch to compare (e.g., 'rivet-xxxx')
     * @returns The diff as a string
     */
    getDiff(projectPath: string, baseBranch: string, compareBranch: string): Promise<string>;
    /**
     * Create a pull request using the GitHub CLI
     * @param projectPath Path to the git repository
     * @param branchName Branch to create PR from
     * @param title PR title
     * @param body PR body/description
     * @param baseBranch Base branch for the PR (default: 'main')
     * @returns The PR URL
     */
    createPullRequest(projectPath: string, branchName: string, title: string, body: string, baseBranch?: string): Promise<string>;
    /**
     * Check if an open pull request exists for the given branch.
     * Returns the PR URL if one exists, null otherwise.
     */
    getExistingPrUrl(projectPath: string, branchName: string): Promise<string | null>;
    private _getExistingPrUrl;
    /**
     * Undo the last commit by resetting HEAD to the previous commit.
     * This is a destructive operation that removes the last commit from history.
     */
    undoLastCommit(projectPath: string): Promise<void>;
    /**
     * Get insertion/deletion stats for all changes relative to a base branch.
     * Compares the working tree against the base, so both committed and uncommitted changes appear.
     */
    getDiffStats(projectPath: string, baseBranch: string): Promise<DiffStats>;
    /**
     * Revert a single file to its state on the base branch
     */
    revertFile(projectPath: string, baseBranch: string, filePath: string): Promise<void>;
    /** Resolve the current HEAD commit SHA. */
    getHeadSha(projectPath: string): Promise<string>;
    /** Get commit messages between the base branch and the current branch head. */
    getCommitLog(projectPath: string, baseBranch: string): Promise<string[]>;
    /**
     * Check whether there are commits on the branch that can be undone.
     * Compares HEAD against the SHA captured at session start so it works
     * even when branchName equals the base branch (e.g. working on main).
     * Pass `currentBranch` to skip an extra subprocess when already known.
     */
    canUndo(projectPath: string, branchName: string, startingSha: string, currentBranch?: string): Promise<boolean>;
}
//# sourceMappingURL=LocalGitService.d.ts.map