@@ -500,6 +500,92 @@ fn lock_sdist_git() -> Result<()> {
500500 Ok ( ( ) )
501501}
502502
503+ /// Lock a Git requirement using PEP 508.
504+ #[ test]
505+ #[ cfg( feature = "git" ) ]
506+ fn lock_sdist_git_subdirectory ( ) -> Result < ( ) > {
507+ let context = TestContext :: new ( "3.12" ) ;
508+
509+ let pyproject_toml = context. temp_dir . child ( "pyproject.toml" ) ;
510+ pyproject_toml. write_str (
511+ r#"
512+ [project]
513+ name = "project"
514+ version = "0.1.0"
515+ requires-python = ">=3.12"
516+ dependencies = ["example-pkg-a @ git+https://github.com/pypa/sample-namespace-packages.git@df7530eeb8fa0cb7dbb8ecb28363e8e36bfa2f45#subdirectory=pkg_resources/pkg_a"]
517+ "# ,
518+ ) ?;
519+
520+ deterministic ! { context =>
521+ uv_snapshot!( context. filters( ) , context. lock( ) , @r###"
522+ success: true
523+ exit_code: 0
524+ ----- stdout -----
525+
526+ ----- stderr -----
527+ warning: `uv lock` is experimental and may change without warning
528+ Resolved 2 packages in [TIME]
529+ "### ) ;
530+
531+ let lock = fs_err:: read_to_string( context. temp_dir. join( "uv.lock" ) ) . unwrap( ) ;
532+
533+ insta:: with_settings!( {
534+ filters => context. filters( ) ,
535+ } , {
536+ assert_snapshot!(
537+ lock, @r###"
538+ version = 1
539+ requires-python = ">=3.12"
540+
541+ [options]
542+ exclude-newer = "2024-03-25 00:00:00 UTC"
543+
544+ [[package]]
545+ name = "example-pkg-a"
546+ version = "1"
547+ source = { git = "https://github.com/pypa/sample-namespace-packages.git?subdirectory=pkg_resources%2Fpkg_a&rev=df7530eeb8fa0cb7dbb8ecb28363e8e36bfa2f45#df7530eeb8fa0cb7dbb8ecb28363e8e36bfa2f45" }
548+
549+ [[package]]
550+ name = "project"
551+ version = "0.1.0"
552+ source = { editable = "." }
553+ dependencies = [
554+ { name = "example-pkg-a" },
555+ ]
556+ "###
557+ ) ;
558+ } ) ;
559+ }
560+
561+ // Re-run with `--locked`.
562+ uv_snapshot ! ( context. filters( ) , context. lock( ) . arg( "--locked" ) , @r###"
563+ success: true
564+ exit_code: 0
565+ ----- stdout -----
566+
567+ ----- stderr -----
568+ warning: `uv lock` is experimental and may change without warning
569+ Resolved 2 packages in [TIME]
570+ "### ) ;
571+
572+ // Install from the lockfile.
573+ uv_snapshot ! ( context. filters( ) , context. sync( ) . arg( "--frozen" ) , @r###"
574+ success: true
575+ exit_code: 0
576+ ----- stdout -----
577+
578+ ----- stderr -----
579+ warning: `uv sync` is experimental and may change without warning
580+ Prepared 2 packages in [TIME]
581+ Installed 2 packages in [TIME]
582+ + example-pkg-a==1 (from git+https://github.com/pypa/sample-namespace-packages.git@df7530eeb8fa0cb7dbb8ecb28363e8e36bfa2f45#subdirectory=pkg_resources/pkg_a)
583+ + project==0.1.0 (from file://[TEMP_DIR]/)
584+ "### ) ;
585+
586+ Ok ( ( ) )
587+ }
588+
503589/// Lock a Git requirement using PEP 508.
504590#[ test]
505591#[ cfg( feature = "git" ) ]
0 commit comments