Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions crates/uv-distribution/src/metadata/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use uv_git_types::{GitReference, GitUrl, GitUrlParseError};
use uv_normalize::{ExtraName, GroupName, PackageName};
use uv_pep440::VersionSpecifiers;
use uv_pep508::{MarkerTree, VerbatimUrl, VersionOrUrl, looks_like_git_repository};
use uv_pypi_types::{ConflictItem, ParsedUrlError, VerbatimParsedUrl};
use uv_pypi_types::{ConflictItem, ParsedGitUrl, ParsedUrlError, VerbatimParsedUrl};
use uv_redacted::DisplaySafeUrl;
use uv_workspace::Workspace;
use uv_workspace::pyproject::{PyProjectToml, Source, Sources};
Expand Down Expand Up @@ -700,17 +700,23 @@ fn path_source(
};
if is_dir {
if let Some(git_member) = git_member {
let git = git_member.git_source.git.clone();
let subdirectory = uv_fs::relative_to(install_path, git_member.fetch_root)
.expect("Workspace member must be relative");
let subdirectory = uv_fs::normalize_path_buf(subdirectory);
let subdirectory = if subdirectory == PathBuf::new() {
None
} else {
Some(subdirectory.into_boxed_path())
};
let url = DisplaySafeUrl::from(ParsedGitUrl {
url: git.clone(),
subdirectory: subdirectory.clone(),
});
return Ok(RequirementSource::Git {
git: git_member.git_source.git.clone(),
subdirectory: if subdirectory == PathBuf::new() {
None
} else {
Some(subdirectory.into_boxed_path())
},
url,
git,
subdirectory,
url: VerbatimUrl::from_url(url),
});
}

Expand Down
4 changes: 3 additions & 1 deletion crates/uv-redacted/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ impl FromStr for DisplaySafeUrl {
}

fn is_ssh_git_username(url: &Url) -> bool {
matches!(url.scheme(), "ssh" | "git+ssh") && url.username() == "git" && url.password().is_none()
matches!(url.scheme(), "ssh" | "git+ssh" | "git+https")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iirc this was cause ssh needs a username while https doesn't, but it doesn't hurt either.

&& url.username() == "git"
&& url.password().is_none()
}

fn display_with_redacted_credentials(
Expand Down
33 changes: 33 additions & 0 deletions crates/uv/tests/it/pip_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17621,3 +17621,36 @@ fn pubgrub_panic_double_self_dependency_extra() -> Result<()> {

Ok(())
}

/// Sync a Git repository that depends on a package within the same repository via a `path` source.
///
/// See: <https://github.com/astral-sh/uv/issues/13020>
#[test]
#[cfg(feature = "git")]
fn git_path_transitive_dependency() -> Result<()> {
let context = TestContext::new("3.13");

let requirements_in = context.temp_dir.child("requirements.in");
requirements_in.write_str(
r"
git+https://[email protected]/astral-sh/uv-path-dependency-test.git#subdirectory=package2
",
)?;

uv_snapshot!(context.filters(), context.pip_compile().arg("requirements.in"), @r"
success: true
exit_code: 0
----- stdout -----
# This file was autogenerated by uv via the following command:
# uv pip compile --cache-dir [CACHE_DIR] requirements.in
package1 @ git+https://[email protected]/astral-sh/uv-path-dependency-test.git@28781b32cf1f260cdb2c8040628079eb265202bd#subdirectory=package1
# via package2
package2 @ git+https://[email protected]/astral-sh/uv-path-dependency-test.git@28781b32cf1f260cdb2c8040628079eb265202bd#subdirectory=package2
# via -r requirements.in

----- stderr -----
Resolved 2 packages in [TIME]
");

Ok(())
}
Loading