Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 59 additions & 1 deletion apps/server/src/git/Layers/GitCore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,64 @@ it.layer(TestLayer)("git integration", (it) => {
}),
);

it.effect("parses separate branch names when column.ui is always enabled", () =>
Effect.gen(function* () {
const tmp = yield* makeTmpDir();
const { initialBranch } = yield* initRepoWithCommit(tmp);
const createdBranchNames = [
"go-bin",
"copilot/rewrite-cli-in-go",
"copilot/rewrite-cli-in-rust",
] as const;
for (const branchName of createdBranchNames) {
yield* (yield* GitCore).createBranch({ cwd: tmp, branch: branchName });
}
yield* git(tmp, ["config", "column.ui", "always"]);

const rawBranchOutput = yield* git(tmp, ["branch", "--no-color"], {
...process.env,
COLUMNS: "120",
});
expect(
rawBranchOutput
.split("\n")
.some(
(line) =>
createdBranchNames.filter((branchName) => line.includes(branchName)).length >= 2,
),
).toBe(true);

const realGitCore = yield* GitCore;
const core = yield* makeIsolatedGitCore((input) =>
realGitCore.execute(
input.args[0] === "branch"
? {
...input,
env: { ...input.env, COLUMNS: "120" },
}
: input,
),
);

const result = yield* core.listBranches({ cwd: tmp });
const localBranchNames = result.branches
.filter((branch) => !branch.isRemote)
.map((branch) => branch.name);

expect(localBranchNames).toHaveLength(4);
expect(localBranchNames).toEqual(
expect.arrayContaining([initialBranch, ...createdBranchNames]),
);
expect(
localBranchNames.some(
(branchName) =>
createdBranchNames.filter((createdBranch) => branchName.includes(createdBranch))
.length >= 2,
),
).toBe(false);
}),
);

it.effect("isDefault is false when no remote exists", () =>
Effect.gen(function* () {
const tmp = yield* makeTmpDir();
Expand Down Expand Up @@ -1824,7 +1882,7 @@ it.layer(TestLayer)("git integration", (it) => {
let didFailRemoteBranches = false;
let didFailRemoteNames = false;
const core = yield* makeIsolatedGitCore((input) => {
if (input.args.join(" ") === "branch --no-color --remotes") {
if (input.args.join(" ") === "branch --no-color --no-column --remotes") {
didFailRemoteBranches = true;
return Effect.fail(
new GitCommandError({
Expand Down
7 changes: 4 additions & 3 deletions apps/server/src/git/Layers/GitCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1423,7 +1423,7 @@ export const makeGitCore = Effect.fn("makeGitCore")(function* (options?: {
const localBranchResult = yield* executeGit(
"GitCore.listBranches.branchNoColor",
input.cwd,
["branch", "--no-color"],
["branch", "--no-color", "--no-column"],
{
timeoutMs: 10_000,
allowNonZeroExit: true,
Expand All @@ -1438,15 +1438,15 @@ export const makeGitCore = Effect.fn("makeGitCore")(function* (options?: {
return yield* createGitCommandError(
"GitCore.listBranches",
input.cwd,
["branch", "--no-color"],
["branch", "--no-color", "--no-column"],
stderr || "git branch failed",
);
}

const remoteBranchResultEffect = executeGit(
"GitCore.listBranches.remoteBranches",
input.cwd,
["branch", "--no-color", "--remotes"],
["branch", "--no-color", "--no-column", "--remotes"],
{
timeoutMs: 10_000,
allowNonZeroExit: true,
Expand Down Expand Up @@ -1814,6 +1814,7 @@ export const makeGitCore = Effect.fn("makeGitCore")(function* (options?: {
runGitStdout("GitCore.listLocalBranchNames", cwd, [
"branch",
"--list",
"--no-column",
"--format=%(refname:short)",
]).pipe(
Effect.map((stdout) =>
Expand Down
Loading