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 into
main fromrefs/pull/2443/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
- apps/server/src/git/Utils.ts lines 13 to 29OutdatedResolvedby imabdulazeez(GitHub profile, opens in a new tab)@@ -11,5 +11,19 @@11-import { join } from "node:path";11+import { dirname, join, parse } from "node:path";12121313 export function isGitRepository(cwd: string): boolean {14- return existsSync(join(cwd, ".git"));14+ const root = parse(cwd).root;15+ let current = cwd;16+ while (true) {17+ if (existsSync(join(current, ".git"))) {18+ return true;19+ }20+ if (current === root) {21+ return false;22+ }23+ const parent = dirname(current);24+ if (parent === current) {25+ return false;26+ }27+ current = parent;28+ }1529 }
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:S
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XS
- apps/server/src/git/Utils.ts lines 4 to 9Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -8,8 +8,11 @@88 import { TextGenerationError } from "@t3tools/contracts";991010 import { existsSync } from "node:fs";11-import { join } from "node:path";11+import { dirname, join } from "node:path";121213-export function isGitRepository(cwd: string): boolean {14- return existsSync(join(cwd, ".git"));13+export function isGitRepository(current: string): boolean {14+ while (current !== (current = dirname(current))) {15+ if (existsSync(join(current, ".git"))) return true;16+ }17+ return false;1518 }
gameroman(GitHub profile, opens in a new tab) approved these changes
imabdulazeez(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID:
c5983499-a0b6-49f4-8e3d-90748805a472You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share