Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): avoid expensive diff minimization in status refreshes #21872

Mergedvoltcrash(GitHub profile, opens in a new tab)merged 3 commits intomain fromrefs/pull/21872/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Showing 2 changed files with 61 additions and 1 deletion.

x
0 of 2 viewed, 2 left
60 additions and 0 deletionsapps/server/src/vcs/GitVcsDriverCore.test.tsModified
View file
@@ -3158,6 +3158,66 @@
+ it.effect("reads Changes totals without minimizing and keeps review diffs minimal", () =>
+ Effect.gen(function* () {
+ const cwd = yield* makeTmpDir();
+ const { initialBranch } = yield* initRepoWithCommit(cwd);
+ const driver = yield* GitVcsDriver.GitVcsDriver;
+ yield* git(cwd, ["config", "diff.algorithm", "myers"]);
+ // Repeated lines make the default and minimal algorithms choose different edits.
+ const lines = Array.from({ length: 2000 }, (_, index) => index);
+ yield* writeTextFile(
+ cwd,
+ "repeated.txt",
+ lines.map((index) => `${(index ^ (index >> 3)) % 16}\n`).join(""),
+ );
+ yield* git(cwd, ["add", "."]);
+ yield* git(cwd, ["commit", "-m", "repeated lines"]);
+ yield* git(cwd, ["checkout", "-b", "feature/totals"]);
+ yield* writeTextFile(
+ cwd,
+ "repeated.txt",
+ lines.map((index) => `${(index ^ (index >> 5)) % 16}\n`).join(""),
+ );
+ const defaultStat = yield* git(cwd, ["diff", "--numstat", "HEAD", "--"]);
+ const minimalStat = yield* git(cwd, ["diff", "--minimal", "--numstat", "HEAD", "--"]);
+ assert.notEqual(defaultStat, minimalStat);
+ const [insertions, deletions] = defaultStat.split("\t");
+ const status = yield* driver.statusDetailsLocal(cwd, { includeBranchChanges: true });