diff --git a/apps/server/src/git/Utils.ts b/apps/server/src/git/Utils.ts index 15015e8cda..139229a48e 100644 --- a/apps/server/src/git/Utils.ts +++ b/apps/server/src/git/Utils.ts @@ -8,10 +8,13 @@ import { Schema } from "effect"; import { TextGenerationError } from "@t3tools/contracts"; import { existsSync } from "node:fs"; -import { join } from "node:path"; +import { dirname, join } from "node:path"; -export function isGitRepository(cwd: string): boolean { - return existsSync(join(cwd, ".git")); +export function isGitRepository(current: string): boolean { + do { + if (existsSync(join(current, ".git"))) return true; + } while (current !== (current = dirname(current))); + return false; } /** Convert an Effect Schema to a flat JSON Schema object, inlining `$defs` when present. */