INNER CODE UNIT · TypeScript

detectGitRepo

modem-dev/hunk · packages/hunk-git/src/index.ts:92

function detectGitRepo(cwd: string) {
  let current = resolve(cwd);
  for (;;) {
    if (fs.existsSync(join(current, ".git"))) {
      return { id: "git" as const, repoRoot: current };
    }
    const parent = dirname(current);
    if (parent === current) {
      return null;
    }
    current = parent;
  }
}

/** Format one file stat into a stable signature fragment, or mark the path missing. */
export function statSignature(path: string) {
  if (!fs.existsSync(path)) {
    return `${path}:missing`;

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…