// src/actions/gitlint-fix.ts
import chalk from "chalk";

// src/lib/gitConfig.ts
import { execFileSync } from "child_process";
function getGitConfig(key) {
  try {
    const value = execFileSync("git", ["config", "--get", key], {
      encoding: "utf8",
      stdio: ["ignore", "pipe", "ignore"]
    }).trim();
    return value.length > 0 ? value : void 0;
  } catch {
    return void 0;
  }
}
function getGitConfigBool(key) {
  try {
    const value = execFileSync("git", ["config", "--bool", "--get", key], {
      encoding: "utf8",
      stdio: ["ignore", "pipe", "ignore"]
    }).trim();
    if (value === "true") return true;
    if (value === "false") return false;
    return void 0;
  } catch {
    return void 0;
  }
}
function setGitConfig(key, value) {
  execFileSync("git", ["config", key, value], { stdio: "inherit" });
}

// src/actions/gitlint-fix.ts
function gitlintFix() {
  console.log(`
Gitlint Fix Start [${process.cwd()}]
`);
  if (getGitConfigBool("core.ignorecase") === true) {
    setGitConfig("core.ignorecase", "false");
    console.warn(chalk.yellow("\nGitlint Fix: Updated core.ignorecase to be false\n"));
  }
  if (getGitConfigBool("core.autocrlf") !== false) {
    setGitConfig("core.autocrlf", "false");
    console.warn(chalk.yellow("\nGitlint Fix: Updated core.autocrlf to be false\n"));
  }
  if (getGitConfig("core.eol") !== "lf") {
    setGitConfig("core.eol", "lf");
    console.warn(chalk.yellow('\nGitlint Fix: Updated core.eol to be "lf"\n'));
  }
  return 1;
}
export {
  gitlintFix
};
//# sourceMappingURL=gitlint-fix.mjs.map