
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="d7f08b41-f173-5a70-ac75-ca31c7acbb42")}catch(e){}}();
import { runGit } from "./git-utils.js";
export async function initializeGitRepository(projectPath) {
    const result = await runGit(projectPath, ["init"]);
    if (!result.ok) {
        return {
            ok: false,
            error: result.error ?? "Failed to initialize git repository.",
        };
    }
    return ensureInitialCommit(projectPath);
}
export async function ensureInitialCommit(projectPath) {
    const headCheck = await runGit(projectPath, ["rev-parse", "--verify", "HEAD"]);
    if (headCheck.ok) {
        return { ok: true, error: null };
    }
    const addResult = await runGit(projectPath, ["add", "-A"]);
    if (!addResult.ok) {
        return {
            ok: false,
            error: addResult.error ?? "Failed to stage files for initial commit.",
        };
    }
    const commitResult = await runGit(projectPath, [
        "commit",
        "--allow-empty",
        "-m",
        "Initial commit through Cline Kanban",
    ]);
    if (!commitResult.ok) {
        return {
            ok: false,
            error: commitResult.error ?? "Failed to create initial commit.",
        };
    }
    return { ok: true, error: null };
}
//# sourceMappingURL=initialize-repo.js.map
//# debugId=d7f08b41-f173-5a70-ac75-ca31c7acbb42
