@@ -450,4 +450,48 @@ if Pkg.Registry.registry_use_pkg_server()
450450 end
451451end
452452
453+ @testset " gc runs git gc on registries" begin
454+ # Only run this test if git is available
455+ if Sys. which (" git" ) != = nothing
456+ temp_pkg_dir () do depot
457+ # Set up a test registry that is a git repository
458+ regdir = mktempdir ()
459+ regpath = joinpath (regdir, " TestReg" )
460+ mkpath (joinpath (regpath, " TestPkg" ))
461+ write (
462+ joinpath (regpath, " Registry.toml" ), """
463+ name = "TestReg"
464+ uuid = "$(uuid4 ()) "
465+ repo = "https://github.com/test/test.git"
466+ """
467+ )
468+ write (
469+ joinpath (regpath, " TestPkg" , " Package.toml" ), """
470+ name = "TestPkg"
471+ uuid = "$(uuid4 ()) "
472+ repo = "https://github.com/test/TestPkg.git"
473+ """
474+ )
475+ git_init_and_commit (regpath)
476+
477+ # Install the registry
478+ target_reg_path = joinpath (depot, " registries" , " TestReg" )
479+ mkpath (dirname (target_reg_path))
480+ cp (regpath, target_reg_path)
481+
482+ # Verify the registry is a git repository
483+ @test isdir (joinpath (target_reg_path, " .git" ))
484+
485+ # Run Pkg.gc() - it should run git gc on the registry without errors
486+ # We can't easily verify that git gc was run, but we can verify
487+ # that Pkg.gc() completes without errors
488+ @test_nowarn Pkg. gc (verbose = false )
489+
490+ # The registry should still exist after gc
491+ @test isdir (target_reg_path)
492+ @test isdir (joinpath (target_reg_path, " .git" ))
493+ end
494+ end
495+ end
496+
453497end # module
0 commit comments