mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-03-12 17:37:24 +00:00
Fix path resolution for git file operations when project directories include spaces or when API calls are issued from subdirectories inside a repository. Problem - operations like commit/discard/diff could receive file paths that were valid from repo root but were executed from a nested cwd - this produced pathspec errors like: - warning: could not open directory '4/4/' - fatal: pathspec '4/hello_world.ts' did not match any files Root cause - file arguments were passed directly to git commands using the project cwd - inconsistent path forms (repo-root-relative vs cwd-relative) were not normalized Changes - remove unsafe fallback decode in `getActualProjectPath`; fail explicitly when the real project path cannot be resolved - add repository/file-path helpers: - `getRepositoryRootPath` - `normalizeRepositoryRelativeFilePath` - `parseStatusFilePaths` - `buildFilePathCandidates` - `resolveRepositoryFilePath` - update file-based git endpoints to resolve paths before executing commands: - GET `/diff` - GET `/file-with-diff` - POST `/commit` - POST `/generate-commit-message` - POST `/discard` - POST `/delete-untracked` - stage/restore/reset operations now use `--` before pathspecs for safer argument separation Behavioral impact - git operations now work reliably for repositories under directories containing spaces - file operations are consistent even when project cwd is a subdirectory of repo root - endpoint responses continue to preserve existing payload shapes Verification - syntax check: `node --check server/routes/git.js` - typecheck: `npm run typecheck` - reproduced failing scenario in a temp path with spaces; confirmed root-resolved path staging succeeds where subdir-cwd pathspec previously failed