The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 25, 07:30 UTC
fix(server): parse git branches correctly when column.ui is enabled (#1529)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
EDM115 committed
Apr 1, 2026 at 03:02 UTC
19eb9e7227b2daad4e77fc2ae91814c1dae0875d
2 files changed
+63
-4
apps/server/src/git/Layers/GitCore.test.ts
+59
-1
@@ -369,6 +369,64 @@ it.layer(TestLayer)("git integration", (it) => {
369
}),
370
);
371
372
+ it.effect("parses separate branch names when column.ui is always enabled", () =>
373
+ Effect.gen(function* () {
374
+ const tmp = yield* makeTmpDir();
375
+ const { initialBranch } = yield* initRepoWithCommit(tmp);
376
+ const createdBranchNames = [
377
+ "go-bin",
378
+ "copilot/rewrite-cli-in-go",
379
+ "copilot/rewrite-cli-in-rust",
380
+ ] as const;
381
+ for (const branchName of createdBranchNames) {
382
+ yield* (yield* GitCore).createBranch({ cwd: tmp, branch: branchName });
383
+ }
384
+ yield* git(tmp, ["config", "column.ui", "always"]);
385
+
386
+ const rawBranchOutput = yield* git(tmp, ["branch", "--no-color"], {
387
+ ...process.env,
388
+ COLUMNS: "120",
389
+ });
390
+ expect(
391
+ rawBranchOutput
392
+ .split("\n")
393
+ .some(
394
+ (line) =>
395
+ createdBranchNames.filter((branchName) => line.includes(branchName)).length >= 2,
396
+ ),
397
+ ).toBe(true);
398
+
399
+ const realGitCore = yield* GitCore;
400
+ const core = yield* makeIsolatedGitCore((input) =>
401
+ realGitCore.execute(
402
+ input.args[0] === "branch"
403
+ ? {
404
+ ...input,
405
+ env: { ...input.env, COLUMNS: "120" },
406
+ }
407
+ : input,
408
+ ),
409
+ );
410
+
411
+ const result = yield* core.listBranches({ cwd: tmp });
412
+ const localBranchNames = result.branches
413
+ .filter((branch) => !branch.isRemote)
414
+ .map((branch) => branch.name);
415
+
416
+ expect(localBranchNames).toHaveLength(4);
417
+ expect(localBranchNames).toEqual(
418
+ expect.arrayContaining([initialBranch, ...createdBranchNames]),
419
+ );
420
+ expect(
421
+ localBranchNames.some(
422
+ (branchName) =>
423
+ createdBranchNames.filter((createdBranch) => branchName.includes(createdBranch))
424
+ .length >= 2,
425
+ ),
426
+ ).toBe(false);
427
+ }),
428
+ );
429
+
430
it.effect("isDefault is false when no remote exists", () =>
431
Effect.gen(function* () {
432
const tmp = yield* makeTmpDir();
@@ -1898,7 +1956,7 @@ it.layer(TestLayer)("git integration", (it) => {
1956
let didFailRemoteBranches = false;
1957
let didFailRemoteNames = false;
1958
const core = yield* makeIsolatedGitCore((input) => {
1901
- if (input.args.join(" ") === "branch --no-color --remotes") {
1959
+ if (input.args.join(" ") === "branch --no-color --no-column --remotes") {
1960
didFailRemoteBranches = true;
1961
return Effect.fail(
1962
new GitCommandError({
apps/server/src/git/Layers/GitCore.ts
+4
-3
@@ -1566,7 +1566,7 @@ export const makeGitCore = Effect.fn("makeGitCore")(function* (options?: {
1566
const localBranchResult = yield* executeGit(
1567
"GitCore.listBranches.branchNoColor",
1568
input.cwd,
1569
- ["branch", "--no-color"],
1569
+ ["branch", "--no-color", "--no-column"],
1570
{
1571
timeoutMs: 10_000,
1572
allowNonZeroExit: true,
@@ -1581,7 +1581,7 @@ export const makeGitCore = Effect.fn("makeGitCore")(function* (options?: {
1581
return yield* createGitCommandError(
1582
"GitCore.listBranches",
1583
input.cwd,
1584
- ["branch", "--no-color"],
1584
+ ["branch", "--no-color", "--no-column"],
1585
stderr || "git branch failed",
1586
);
1587
}
@@ -1589,7 +1589,7 @@ export const makeGitCore = Effect.fn("makeGitCore")(function* (options?: {
1589
const remoteBranchResultEffect = executeGit(
1590
"GitCore.listBranches.remoteBranches",
1591
input.cwd,
1592
- ["branch", "--no-color", "--remotes"],
1592
+ ["branch", "--no-color", "--no-column", "--remotes"],
1593
{
1594
timeoutMs: 10_000,
1595
allowNonZeroExit: true,
@@ -1957,6 +1957,7 @@ export const makeGitCore = Effect.fn("makeGitCore")(function* (options?: {
1957
runGitStdout("GitCore.listLocalBranchNames", cwd, [
1958
"branch",
1959
"--list",
1960
+ "--no-column",
1961
"--format=%(refname:short)",
1962
]).pipe(
1963
Effect.map((stdout) =>