From fe2bc079bc68c6093adeb376c9c772ccb87fbfe3 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Fri, 17 May 2024 17:45:46 -0400 Subject: [PATCH] Use `ParsedGitUrl` to recreate Git source kind URL (#3647) --- crates/uv-resolver/src/lock.rs | 12 +++++++----- crates/uv/tests/lock.rs | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/crates/uv-resolver/src/lock.rs b/crates/uv-resolver/src/lock.rs index 38500d963..5cea21f08 100644 --- a/crates/uv-resolver/src/lock.rs +++ b/crates/uv-resolver/src/lock.rs @@ -12,8 +12,9 @@ use url::Url; use distribution_filename::WheelFilename; use distribution_types::{ BuiltDist, DirectUrlBuiltDist, DirectUrlSourceDist, DirectorySourceDist, Dist, FileLocation, - GitSourceDist, IndexUrl, ParsedArchiveUrl, PathBuiltDist, PathSourceDist, RegistryBuiltDist, - RegistryBuiltWheel, RegistrySourceDist, Resolution, ResolvedDist, ToUrlError, + GitSourceDist, IndexUrl, ParsedArchiveUrl, ParsedGitUrl, PathBuiltDist, PathSourceDist, + RegistryBuiltDist, RegistryBuiltWheel, RegistrySourceDist, Resolution, ResolvedDist, + ToUrlError, }; use pep440_rs::Version; use pep508_rs::{MarkerEnvironment, VerbatimUrl}; @@ -310,9 +311,10 @@ impl Distribution { .with_precise(git.precise); // Reconstruct the PEP 508-compatible URL from the `GitSource`. - // TODO(charlie): This shouldn't be necessary; it's only necessary because we're - // still losing the `GitUrl` somewhere along the path to installation. - let url = Url::from(git_url.clone()); + let url = Url::from(ParsedGitUrl { + url: git_url.clone(), + subdirectory: git.subdirectory.as_ref().map(PathBuf::from), + }); let git_dist = GitSourceDist { name: self.id.name.clone(), diff --git a/crates/uv/tests/lock.rs b/crates/uv/tests/lock.rs index 2afed75e1..af8694100 100644 --- a/crates/uv/tests/lock.rs +++ b/crates/uv/tests/lock.rs @@ -300,7 +300,7 @@ fn lock_git() -> Result<()> { ----- stderr ----- Downloaded 4 packages in [TIME] Installed 5 packages in [TIME] - + anyio==3.7.0 (from https://github.com/agronholm/anyio@f7a880ffac4766efb39e6fb60fc28d944f5d2f65) + + anyio==3.7.0 (from git+https://github.com/agronholm/anyio@f7a880ffac4766efb39e6fb60fc28d944f5d2f65) + exceptiongroup==1.2.0 + idna==3.6 + sniffio==1.3.1