diff --git a/apps/server/src/git/Utils.ts b/apps/server/src/git/Utils.ts index 6faf3e99c77..b594559b5b0 100644 --- a/apps/server/src/git/Utils.ts +++ b/apps/server/src/git/Utils.ts @@ -1,6 +1,9 @@ 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; }