fix(paths): handle cwd-relative input in validate_for_add / validate_for_get#192
Draft
CGMossa wants to merge 1 commit into
Draft
fix(paths): handle cwd-relative input in validate_for_add / validate_for_get#192CGMossa wants to merge 1 commit into
CGMossa wants to merge 1 commit into
Conversation
3 tasks
Contributor
Author
|
from vincent
I believe this means that this PR adds an unnecessary mechanism. I need to read the code and understand this bit. While dvs-lib is very excellently written, it is hard both for me and AI to follow what happens. |
3579d3e to
443abcb
Compare
443abcb to
79e65df
Compare
…ive input When the user is in a subdirectory of the repo, they type paths relative to their cwd (e.g. \`file.bin\` from \`/repo/sub/\`). The \`validate_for_*\` checks today do \`self.repo_root.join(path)\`, which anchors at the wrong directory and only works correctly when the caller has already converted to a repo-relative form. That conversion currently lives inside \`resolve_paths_for_add\` / \`resolve_paths_for_get\`, which means callers that want per-row \`AddDetail::Error\` / \`GetDetail::Error\` rows (rather than the bail on canonicalize failure that \`resolve_paths_*\` does) can't bypass those helpers — they need the conversion side-effect. Move the cwd→repo-relative conversion into the validators (private \`DvsPaths::user_path_to_repo_relative\`). Now callers can hand user input straight to \`add_files\` / \`get_files\` and the per-row error machinery in \`validate_for_*\` does the right thing. The returned tuple carries the repo-relative form so downstream \`file_path\` / \`metadata_path\` calls remain correct. CLI behavior unchanged: it still calls \`resolve_paths_for_*\` which still bails on missing paths.
79e65df to
2270fcf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
validate_for_add/validate_for_getpath checks expect repo-relative paths, but callers running from a subdir hand them cwd-relative input. Today the cwd→repo-relative conversion lives insideresolve_paths_for_*, so any caller that wants per-rowErrorrows (instead of the bail-on-canonicalize-failure behavior) has no way to skip the resolver without losing the conversion. This moves the conversion into the validators themselves so per-row classification works against raw user input. CLI behavior unchanged — it still callsresolve_paths_for_*. Required by #193, which uses the per-row form from the R binding.AI-written details
Summary
validate_for_*previously didself.repo_root.join(path), which only matched when the caller had already converted to repo-relative form (the side-effect of going throughresolve_paths_for_*).DvsPaths::user_path_to_repo_relativehandles the cwd→repo-relative conversion, and the returned tuple carries the repo-relative form so downstreamfile_path/metadata_pathcalls keep working.add_files/get_filesand the per-rowAddDetail::Error/GetDetail::Errormachinery invalidate_for_*does the right thing.Test plan
cargo test -p dvs --libpasses (existingvalidate_for_addtest coversValid/NotFound/OutsideProject/IsDirectory)dvs add missing.binfrom a subdir unchanged (CLI still routes throughresolve_paths_for_addwhich still bails on canonicalize failure)ui/main_events.shNotes
resolve_paths_for_*which keeps its bail-on-missing behavior. This PR only makes the per-row path usable for callers that want to skip the resolver.resolve_paths_for_*when no glob is supplied and relies on the per-row classification this PR makes accessible.Drafted by Claude (claude-opus-4-7). Reviewed by the author.