Use correct lock path for workspace dependencies (#4421)

Previously, distributions created through `Source::Workspace` would have
the absolute path as lock path. This didn't cause any problems, since in
`Urls` we would later overwrite those urls with the correct one created
from being workspace members by path.

Changing the order surfaced this. This change emits the correct lock
path. I've manually checked the difference with `dbg!`, this is not
observable on main, but on the diverging urls branch it fixes lockfile
creation.
This commit is contained in:
konsti 2024-06-20 15:28:47 +02:00 committed by GitHub
parent fc7c318dd0
commit b865341517
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 48 additions and 71 deletions

View file

@ -332,8 +332,9 @@ pub fn relative_to(path: impl AsRef<Path>, base: impl AsRef<Path>) -> Result<Pat
.as_ref()
.ancestors()
.find_map(|ancestor| {
path.as_ref()
.strip_prefix(ancestor)
// Simplifying removes the UNC path prefix on windows.
dunce::simplified(path.as_ref())
.strip_prefix(dunce::simplified(ancestor))
.ok()
.map(|stripped| (stripped, ancestor))
})
@ -342,8 +343,8 @@ pub fn relative_to(path: impl AsRef<Path>, base: impl AsRef<Path>) -> Result<Pat
io::ErrorKind::Other,
format!(
"Trivial strip failed: {} vs. {}",
path.simplified_display(),
base.simplified_display()
path.as_ref().simplified_display(),
base.as_ref().simplified_display()
),
)
})?;