Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update manifest entry of project for non-local manifests (#3579) #3594

Closed
wants to merge 1 commit into from
Closed
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
13 changes: 9 additions & 4 deletions src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -922,10 +922,15 @@ end
project_rel_path(env::EnvCache, path::String) = normpath(joinpath(dirname(env.manifest_file), path))

function prune_manifest(env::EnvCache)
# if project uses another manifest, don't prune
dirname(env.project_file) != dirname(env.manifest_file) && return env.manifest
keep = collect(values(env.project.deps))
env.manifest = prune_manifest(env.manifest, keep)
# if project uses another manifest, only prune project entry in manifest
if dirname(env.project_file) != dirname(env.manifest_file)
proj_entry = env.manifest[env.project.uuid]
proj_entry.deps = env.project.deps
else
keep = collect(values(env.project.deps))
env.manifest = prune_manifest(env.manifest, keep)
end
return env.manifest
end

function prune_manifest(manifest::Manifest, keep::Vector{UUID})
Expand Down
22 changes: 21 additions & 1 deletion test/project_manifest.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module ProjectManifestTest

import ..Pkg # ensure we are using the correct Pkg
using Test, Pkg
using Test, Pkg, UUIDs
using ..Utils

temp_pkg_dir() do project_path
Expand Down Expand Up @@ -29,13 +29,33 @@ temp_pkg_dir() do project_path
Pkg.test()
end
end
m = Pkg.Types.read_manifest(joinpath(dir, "monorepo", "Manifest.toml"))
@test haskey(m, UUID("dd0d8fba-d7c4-4f8e-a2bb-3a090b3e34f2")) # B subpackage
@test haskey(m, UUID("4ee78ca3-4e78-462f-a078-747ed543fa86")) # C subpackage
@test haskey(m, UUID("bf733257-898a-45a0-b2f2-c1c188bdd870")) # D subpackage, but no direct dependency
pkgC = m[UUID("4ee78ca3-4e78-462f-a078-747ed543fa86")]
@test haskey(pkgC.deps, "D")
cd(joinpath(dir, "monorepo")) do
with_current_env() do
Pkg.develop(path="packages/C")
Pkg.add("Test")
Pkg.test()
end
end
# now test removing a dependency from subpackage correctly updates root manifest
cd(joinpath(dir, "monorepo", "packages", "C")) do
with_current_env() do
Pkg.rm("D")
Pkg.test()
end
end
m = Pkg.Types.read_manifest(joinpath(dir, "monorepo", "Manifest.toml"))
# currently, we don't prune dependencies from the root manifest since when rm-ing a dep
# in a subpackage, we don't also do a full resolve at the root level
# https://github.com/JuliaLang/Pkg.jl/issues/3590
@test_broken !haskey(m, UUID("bf733257-898a-45a0-b2f2-c1c188bdd870")) # D subpackage, but no direct dependency
pkgC = m[UUID("4ee78ca3-4e78-462f-a078-747ed543fa86")]
@test !haskey(pkgC.deps, "D")
end
end
end
Expand Down