Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): detect git repo from subdirectories so diffs and checkpoints work in monorepos #2443

Closedimabdulazeez(GitHub profile, opens in a new tab)wants to merge 4 commits intomain fromrefs/pull/2443/headopened View on GitHub

Showing 1 changed file with 6 additions and 3 deletions.

x
0 of 1 viewed, 1 left
6 additions and 3 deletionsapps/server/src/git/Utils.tsModified
View file
@@ -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;
}