perf(server): git status runs in parallel and repo detection spawns 3x fewer git processes #27103
Mergedjuliusmarmingemerged 2 commits into
main fromrefs/pull/27103/headmerged by juliusmarminge View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/server/src/vcs/GitVcsDriver.ts line 590Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -587,12 +587,4 @@587587 const detectRepository: VcsDriver.VcsDriver["Service"]["detectRepository"] = Effect.fn(588588 "detectRepository",589589 )(function* (cwd) {590- if (!(yield* isInsideWorkTree(cwd))) {591- return null;592- }593-594- const root = yield* gitCommand(vcsProcess, "GitVcsDriver.detectRepository.root", cwd, [595- "rev-parse",596- "--show-toplevel",597- ]);598- const gitCommonDir = yield* gitCommand(590+ // One spawn answers all three; outside a work tree it exits non-zero or prints "false".
- @@ -3014,3 +3020,4 @@30143020 cwd: string,30153021 branch: string | null,30163022 explicitBaseRef?: string,3023+ knownOriginDefaultBranch: string | null = null,
juliusmarminge changed the title
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
- apps/server/src/vcs/GitVcsDriver.ts line 617Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -603,0 +597,21 @@597+ allowNonZeroExit: true,598+ timeoutMs: 5_000,599+ maxOutputBytes: 16_384,600+ },601+ ).pipe(Effect.catchIf(isMissingExecutable, () => Effect.succeed(null)));602+ if (result === null || result.exitCode !== 0) return null;603+ const lines = result.stdout.replace(/\r?\n$/u, "").split(/\r?\n/u);604+ if (lines[0]?.trim() !== "true") return null;605+ // A newline inside a path breaks the line framing; ask for each path on its own.606+ if (lines.length !== 3) {607+ const root = yield* gitCommand(vcsProcess, "GitVcsDriver.detectRepository", cwd, [608+ "rev-parse",609+ "--show-toplevel",610+ ]);611+ const gitCommonDir = yield* gitCommand(vcsProcess, "GitVcsDriver.detectRepository", cwd, [612+ "rev-parse",613+ "--git-common-dir",614+ ]).pipe(Effect.orElseSucceed(() => null));615+ return {616+ kind: "git" as const,617+ rootPath: root.stdout.trim(),
juliusmarminge merged this7c29f2d
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed