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

// src/lib/gitConfig.ts
import { execFileSync } from "node: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;
  }
}

// src/lib/reporting/xyReporter.ts
var strictMode = false;
function isStrictMode() {
  return strictMode || process.env.XY_STRICT === "1";
}

// src/actions/gitlint.ts
function gitlint() {
  console.log(`
Gitlint Start [${process.cwd()}]
`);
  let valid = 0;
  let warnings = 0;
  const errors = 0;
  const warn = (message) => {
    console.warn(chalk.yellow(`Warning: ${message}`));
    warnings++;
  };
  if (getGitConfigBool("core.ignorecase") === true) {
    warn("Please set core.ignorecase to FALSE in .git/config file [run yarn gitlint-fix]");
  } else {
    valid++;
  }
  if (getGitConfigBool("core.autocrlf") === false) {
    valid++;
  } else {
    warn("Please set core.autocrlf to FALSE in .git/config file [run yarn gitlint-fix]");
  }
  if (getGitConfig("core.eol") === "lf") {
    valid++;
  } else {
    warn('Please set core.eol to "lf" in .git/config file [run yarn gitlint-fix]');
  }
  const resultMessages = [];
  if (valid > 0) {
    resultMessages.push(chalk.green(`Passed: ${valid}`));
  }
  if (warnings > 0) {
    resultMessages.push(chalk.yellow(`Warnings: ${warnings}`));
  }
  if (errors > 0) {
    resultMessages.push(chalk.red(` Errors: ${errors}`));
  }
  console.warn(`Gitlint Finish [ ${resultMessages.join(" | ")} ]
`);
  return errors + (isStrictMode() ? warnings : 0);
}
export {
  gitlint
};
//# sourceMappingURL=gitlint.mjs.map
