fix(opencode): normalize subdirectory git paths#25631
Conversation
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, I found one potentially related PR (excluding the current PR #25631): Related PR:
However, this is an older feature PR from a different context. The current PR #25631 appears to be the only active PR directly addressing the git path normalization issue for subdirectories (issue #25593). No duplicate PRs found |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Closes #25593
Type of change
What does this PR do?
When opencode is opened from a subdirectory, Git can report paths relative to the repo root. The review UI then tries to read those paths relative to the opened directory and fails.
This normalizes Git status/diff/stat paths to the active directory, reads
git showtargets relative to the active directory, and keeps batched patch keys aligned with the normalized file paths.How did you verify your code works?
From
packages/opencode:bun test --timeout 30000 test/git/git.test.ts -t "show\(\) reads files relative to a subdirectory|status\(\) handles special filenames|diff\(\), stats\(\), and mergeBase|patch\(\) returns capped|show\(\) returns empty text for binary blobs"bun test --timeout 30000 test/project/vcs.test.ts -t "diff\('git'\) returns paths relative to the active subdirectory|diff\('git'\) returns uncommitted changes|diff\('git'\) keeps batched patches aligned"bun test --timeout 30000 test/file/index.test.ts -t "detects modified file|detects modified files relative to a subdirectory|detects untracked file as added|detects deleted file|detects mixed changes|returns empty for non-git project|returns diff and patch for modified tracked file"Screenshots / recordings
Not a UI change.
Checklist