INNER CODE UNIT · TypeScript

isSaplingHgRepo

modem-dev/hunk · packages/hunk-sapling/src/index.ts:38

function isSaplingHgRepo(hgDir: string) {
  try {
    return fs.readFileSync(join(hgDir, "requires"), "utf8").split("\n").includes("treestate");
  } catch {
    return false;
  }
}

/** Walk upward to detect a Sapling workspace marker. `.sl` always matches;
 *  `.hg` only matches when `.hg/requires` contains `treestate` (Sapling-specific). */
function detectSlRepo(cwd: string) {
  let current = resolve(cwd);
  for (;;) {
    if (fs.existsSync(join(current, ".sl"))) {
      return { id: "sl" as const, repoRoot: current };
    }
    const hgDir = join(current, ".hg");
    if (fs.existsSync(hgDir) && isSaplingHgRepo(hgDir)) {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…