Preserve relative paths in lockfiles for flat indices#15870
Preserve relative paths in lockfiles for flat indices#15870harshithvh wants to merge 7 commits intoastral-sh:mainfrom
Conversation
|
hey @konstin |
|
I want to give @charliermarsh a chance to look at this too, afterwards we can merge it. |
|
I will review today. |
|
@konstin, all looks good to me |
| if let Ok(verbatim_url) = VerbatimUrl::from_url_or_path(&index_str, None) { | ||
| IndexMetadata::from(IndexUrl::from(verbatim_url.with_given(&index_str))) | ||
| } else { | ||
| // provide a fallback |
There was a problem hiding this comment.
In which case does the code above fail but the logic below pass?
There was a problem hiding this comment.
Yes, it’s redundant. from_url_or_path already accepts both valid URLs and paths; anything DisplaySafeUrl::parse would accept is already accepted by from_url_or_path.
|
hey @konstin, sorry for keeping this PR hanging. Please review the changes when you have some time |
| @@ -3582,9 +3582,23 @@ impl Source { | |||
| .to_file_path() | |||
| .map_err(|()| LockErrorKind::UrlToPath { url: url.to_url() })?; | |||
| let path = relative_to(&path, root) | |||
There was a problem hiding this comment.
Can you add some documentation around why we need both the relative_to and reading the relative path from given?
There was a problem hiding this comment.
added docs! Hope this helps future readers
There was a problem hiding this comment.
Sorry I still don't follow. When they are on different drives (I assume you mean Windows drive letters, not Unix mounts?), how can the user config use a relative path?
Can you write a test case for this? The current test case passes with only the requirement.rs changes applied.
Summary
Modified
Source::from_index_urlto check the original user input and preserve relative paths when the user originally provided them.fixes: #15055
Test Plan
added
lock_find_links_relative_path_preserved, validates that flat indices preserve relative paths in lockfiles instead of converting them to absolute paths