Resolve file paths relative to repo root#127
Conversation
📝 WalkthroughWalkthroughAdds VcsBackend::get_repository_root and implements it for Git and Jj backends; diff logic now resolves working-tree file reads against the repository root with a fallback to the original filename. Tests added to verify root resolution from subdirectories. Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as CLI/Command
participant Diff as diff::git::WorkingTree
participant VCS as VcsBackend
participant FS as Filesystem
CLI->>Diff: request file diff
Diff->>VCS: get_repository_root()
VCS-->>Diff: repository root path
Diff->>FS: read file at (repo_root + filename)
alt read succeeds
FS-->>Diff: new_content
else fallback
Diff->>FS: read file at original filename
FS-->>Diff: new_content or error
end
Diff-->>CLI: return diff result (includes new_content)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
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
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 |
49f03c5 to
8b63b7a
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/vcs/jj.rs`:
- Around line 973-975: get_repository_root currently returns the stored
self.workspace_path which may be a subdirectory; change get_repository_root to
return the actual workspace root by calling
self.workspace.workspace_root().to_path_buf() instead of using
self.workspace_path so the function returns the correct root loaded by the
Workspace (update the body of fn get_repository_root to return
Ok(self.workspace.workspace_root().to_path_buf())).
When running lumen from a subdirectory, files appeared as "deleted" because get_new_content() resolved paths relative to CWD instead of the repository root. - Add get_repository_root() method to VcsBackend trait - Implement for GitBackend using repo.workdir() - Implement for JjBackend using workspace_path - Update get_new_content() to resolve paths from repo root - Add tests for both the new method and the bug fix
8b63b7a to
94cdff3
Compare
|
This might be duplicate of: #110 |
|
Oh nice. I'm not too familiar with rust either. My pull request was ai assisted. I built and tested it locally for verification to help build confidence. I'll be happy if either pull request gets merged haha. |
Summary
This pull request allows
lumento run correctly from a sub directory. Currently, it can't find the files correctly and treats them as being deleted.Changes
get_repository_root()method toVcsBackendtraitGitBackend(usingrepo.workdir()) andJjBackend(usingworkspace_path)get_new_content()to resolve paths from repo rootTest plan
test_get_repository_root_from_subdirectoryfor GitBackendtest_load_file_diffs_from_subdirectoryintegration testRepro steps
lumen diffNotes
Discovered a pre-existing issue:
JjBackendcannot be loaded from subdirectories becauseWorkspace::load()requires the exact workspace root path (unlike git2'sRepository::discover()which walks up the directory tree). This is unrelated to this fix - the same error occurs on the current release.Summary by CodeRabbit
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.