fix: normalize worktree paths and update branch listing logic

- Updated the branch listing command to remove quotes around branch names, ensuring compatibility across platforms.
- Enhanced worktree path comparisons in tests to normalize path separators, improving consistency between server and client environments.
- Adjusted workspace root resolution to reflect the correct directory structure for the UI.

This addresses potential discrepancies in branch names and worktree paths, particularly on Windows systems.
This commit is contained in:
Kacper
2025-12-17 22:52:40 +01:00
parent bfc8f9bc26
commit 76cb72812f
5 changed files with 27 additions and 15 deletions

View File

@@ -38,8 +38,9 @@ export function createListBranchesHandler() {
const currentBranch = currentBranchOutput.trim();
// List all local branches
// Use %(refname:short) without quotes - quotes are preserved on Windows
const { stdout: branchesOutput } = await execAsync(
"git branch --format='%(refname:short)'",
"git branch --format=%(refname:short)",
{ cwd: worktreePath }
);
@@ -47,11 +48,15 @@ export function createListBranchesHandler() {
.trim()
.split("\n")
.filter((b) => b.trim())
.map((name) => ({
name: name.trim(),
isCurrent: name.trim() === currentBranch,
isRemote: false,
}));
.map((name) => {
// Remove any surrounding quotes (Windows git may preserve them)
const cleanName = name.trim().replace(/^['"]|['"]$/g, "");
return {
name: cleanName,
isCurrent: cleanName === currentBranch,
isRemote: false,
};
});
// Get ahead/behind count for current branch
let aheadCount = 0;