TypeScript
fix(server): generated commit and PR text no longer reads colored git output (#29126)
Alex Southwell50106efdd920
diff --git a/apps/server/src/vcs/GitVcsDriverCore.test.ts b/apps/server/src/vcs/GitVcsDriverCore.test.tsindex 26807326715..f1b964d6ae1 100644--- a/apps/server/src/vcs/GitVcsDriverCore.test.ts+++ b/apps/server/src/vcs/GitVcsDriverCore.test.ts@@ -2714,11 +2714,12 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {}),);- it.effect("reads range patches from source without running textconv", () =>+ it.effect("reads range patches from source without textconv or color", () =>Effect.gen(function* () {const cwd = yield* makeTmpDir();const { initialBranch } = yield* initRepoWithCommit(cwd);yield* git(cwd, ["config", "diff.probe.textconv", "touch textconv-ran; echo converted"]);+ yield* git(cwd, ["config", "color.ui", "always"]);yield* git(cwd, ["checkout", "-b", "feature/range"]);yield* writeTextFile(cwd, ".gitattributes", "*.doc diff=probe\n");yield* writeTextFile(cwd, "notes.doc", "source line\n");@@ -2736,12 +2737,16 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {assert.include(context.diffPatch, "+plain line");assert.include(context.diffPatch, "Binary files /dev/null and b/binary.dat differ");assert.include(context.diffSummary, "notes.doc");+ for (const output of [context.commitSummary, context.diffSummary, context.diffPatch]) {+ assert.notInclude(output, "\u001b[");+ }assert.isFalse(yield* fileSystem.exists(`${cwd}/textconv-ran`));yield* writeTextFile(cwd, "notes.doc", "updated source line\n");const staged = yield* driver.prepareCommitContext(cwd, ["notes.doc"]);assert.include(staged?.stagedPatch ?? "", "+updated source line");assert.notInclude(staged?.stagedPatch ?? "", "converted");+ assert.notInclude(staged?.stagedPatch ?? "", "\u001b[");assert.include(staged?.stagedSummary ?? "", "notes.doc");assert.isFalse(yield* fileSystem.exists(`${cwd}/textconv-ran`));}),diff --git a/apps/server/src/vcs/GitVcsDriverCore.ts b/apps/server/src/vcs/GitVcsDriverCore.tsindex d150ed97791..eab2ba626a2 100644--- a/apps/server/src/vcs/GitVcsDriverCore.ts+++ b/apps/server/src/vcs/GitVcsDriverCore.ts@@ -2530,7 +2530,15 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*const stagedPatch = yield* runGitStdoutWithOptions("GitVcsDriver.prepareCommitContext.stagedPatch",cwd,- ["diff", "--no-ext-diff", "--no-textconv", "--cached", "--patch", "--minimal"],+ [+ "diff",+ "--no-color",+ "--no-ext-diff",+ "--no-textconv",+ "--cached",+ "--patch",+ "--minimal",+ ],{env,maxOutputBytes: PREPARED_COMMIT_PATCH_MAX_OUTPUT_BYTES,@@ -2923,7 +2931,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*runGitStdoutWithOptions("GitVcsDriver.readRangeContext.log",cwd,- ["log", "--oneline", "--end-of-options", commitRange],+ ["log", "--oneline", "--no-color", "--end-of-options", commitRange],{maxOutputBytes: RANGE_COMMIT_SUMMARY_MAX_OUTPUT_BYTES,appendTruncationMarker: true,@@ -2932,7 +2940,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*runGitStdoutWithOptions("GitVcsDriver.readRangeContext.diffStat",cwd,- ["diff", "--stat", "--end-of-options", diffRange],+ ["diff", "--stat", "--no-color", "--end-of-options", diffRange],{maxOutputBytes: RANGE_DIFF_SUMMARY_MAX_OUTPUT_BYTES,appendTruncationMarker: true,@@ -2943,6 +2951,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*cwd,["diff",+ "--no-color","--no-ext-diff","--no-textconv","--patch",