fix: resolve relative paths in working tree diffs using workspace root#110
fix: resolve relative paths in working tree diffs using workspace root#110Straffern wants to merge 2 commits intojnsahaj:mainfrom
Conversation
📝 WalkthroughWalkthroughAdded a runtime workspace-root accessor to VcsBackend and implemented it for Git and Jj. Diff code now resolves working-tree file paths against that workspace root; Jj backend now discovers and stores the workspace root during initialization. (47 words) Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant DiffCmd as Diff Command
participant Vcs as VcsBackend
participant FS as Filesystem
participant Editor
rect rgba(200,230,255,0.5)
User->>DiffCmd: request diff / open file
DiffCmd->>Vcs: get_workspace_root()
Vcs-->>DiffCmd: workspace_root (PathBuf)
DiffCmd->>FS: read file at workspace_root + filename
FS-->>DiffCmd: file contents
DiffCmd->>Editor: launch editor with full path
Editor-->>User: editor opens file
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (4)
🧰 Additional context used🧬 Code graph analysis (1)src/vcs/backend.rs (2)
🔇 Additional comments (2)
✏️ Tip: You can disable this entire section by setting Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hi, the change looks good but I'm curious about the issue you faced, which prompted you to make this change. |
Yeah, I am working from a monorepo and thus often want to execute lumen from within a subdir of the repo root. |
|
Hmm. There might be a bug with this.. When I try and open a file, from lumen diff (e keybinding). What actually happens: |
b8fd44a to
a451725
Compare
This pull request improves how file paths are resolved when reading files from the working tree, ensuring that relative paths are interpreted correctly with respect to the workspace or repository root. The main change is the introduction of a
get_workspace_rootmethod to theVcsBackendtrait, with implementations for both Git and JJ backends. This change ensures consistent and correct file access, especially in cases where the current working directory may differ from the repository root.Disclaimer: I do not know Rust. I have never coded in Rust. The clanker wrote this. I have created/applied a .patch in my NixOS config and it seems to work nicely.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.