TypeScript
perf(server): untracked change totals use less CPU (#19676)
Jetcfbd463110d4
diff --git a/apps/server/src/vcs/GitVcsDriverCore.test.ts b/apps/server/src/vcs/GitVcsDriverCore.test.tsindex 304c2a537fd..254c2f58812 100644--- a/apps/server/src/vcs/GitVcsDriverCore.test.ts+++ b/apps/server/src/vcs/GitVcsDriverCore.test.ts@@ -3221,6 +3221,34 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {}),);+ it.effect(+ "counts many untracked files exactly while collapsing their directory in status",+ () =>+ Effect.gen(function* () {+ const cwd = yield* makeTmpDir();+ yield* initRepoWithCommit(cwd);+ const driver = yield* GitVcsDriver.GitVcsDriver;+ yield* git(cwd, ["branch", "-M", "main"]);+ yield* git(cwd, ["checkout", "-b", "feature/many-untracked"]);+ yield* Effect.forEach(+ Array.from({ length: 1_001 }, (_, index) => `bulk/${index}.txt`),+ (file) => writeTextFile(cwd, file, "one\ntwo\n"),+ { concurrency: 32, discard: true },+ );++ const status = yield* driver.statusDetailsLocal(cwd, { includeBranchChanges: true });+ assert.deepStrictEqual(status.branchChanges, {+ baseRef: "main",+ insertions: 2_002,+ deletions: 0,+ });+ assert.deepStrictEqual(+ status.workingTree.files.map((file) => file.path),+ ["bulk/"],+ );+ }),+ );+it.effect("reports non-repository directories without failing", () =>Effect.gen(function* () {const cwd = yield* makeTmpDir();diff --git a/apps/server/src/vcs/GitVcsDriverCore.ts b/apps/server/src/vcs/GitVcsDriverCore.tsindex 1d706a86c1a..9615ecec213 100644--- a/apps/server/src/vcs/GitVcsDriverCore.ts+++ b/apps/server/src/vcs/GitVcsDriverCore.ts@@ -2861,6 +2861,9 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*cwd,[...tempIndexConfig,+ // Avoid redundant tracked-entry pathspec matching in this disposable index.+ "-c",+ "core.preloadIndex=false","--literal-pathspecs","add","--intent-to-add",