Skip to content

Commit

Permalink
Do not unnecessarily remove entries from compat (2419) (JuliaLang#2450)
Browse files Browse the repository at this point in the history
Co-authored-by: David Varela <[email protected]>
  • Loading branch information
00vareladavid and 00vareladavid authored Mar 24, 2021
1 parent 5b420bb commit 8ad4425
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -997,17 +997,15 @@ function rm(ctx::Context, pkgs::Vector{PackageSpec})
println(ctx.io, "No changes")
return
end
# only declare `compat` for direct dependencies
# only declare `compat` for remaining direct or `extra` dependencies
# `julia` is always an implicit direct dependency
filter!(ctx.env.project.compat) do (name, _)
name == "julia" || name in keys(ctx.env.project.deps)
name == "julia" || name in keys(ctx.env.project.deps) || name in keys(ctx.env.project.extras)
end
deps_names = append!(collect(keys(ctx.env.project.deps)),
collect(keys(ctx.env.project.extras)))
deps_names = union(keys(ctx.env.project.deps), keys(ctx.env.project.extras))
filter!(ctx.env.project.targets) do (target, deps)
!isempty(filter!(in(deps_names), deps))
end

# only keep reachable manifest entires
prune_manifest(ctx.env)
# update project & manifest
Expand Down
10 changes: 10 additions & 0 deletions test/new.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1722,6 +1722,16 @@ end
@test !haskey(Pkg.Types.Context().env.project.compat, "Example")
@test haskey(Pkg.Types.Context().env.project.compat, "julia")
end end
# rm should not unnecessarily remove compat entries
isolate(loaded_depot=true) do; mktempdir() do tempdir
path = copy_test_package(tempdir, "CompatExtras")
Pkg.activate(path)
@test haskey(Pkg.Types.Context().env.project.compat, "Aqua")
@test haskey(Pkg.Types.Context().env.project.compat, "DataFrames")
Pkg.rm("DataFrames")
@test !haskey(Pkg.Types.Context().env.project.compat, "DataFrames")
@test haskey(Pkg.Types.Context().env.project.compat, "Aqua")
end end
# rm removes unused recursive depdencies
isolate(loaded_depot=true) do; mktempdir() do tempdir
path = copy_test_package(tempdir, "SimplePackage")
Expand Down
16 changes: 16 additions & 0 deletions test/test_packages/CompatExtras/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name = "CompatExtras"
uuid = "37f6bc05-9e90-43d5-90c6-4d69d7097606"
version = "0.1.0"

[deps]
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"

[compat]
Aqua = "0.5"
DataFrames = "0.22"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"

[targets]
test = ["Aqua"]

0 comments on commit 8ad4425

Please sign in to comment.