Skip to content

Commit 5dae2d7

Browse files
authored
fix showing dependencies of status package in manifest mode (#4435)
1 parent 5bfd116 commit 5dae2d7

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

src/Operations.jl

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2944,7 +2944,27 @@ function print_status(
29442944
printpkgstyle(io, :Project, "No packages added to or removed from $(pathrepr(env.project_file))", ignore_indent; color = Base.info_color())
29452945
end
29462946
else
2947-
xs = !filter ? xs : eltype(xs)[(id, old, new) for (id, old, new) in xs if (id in uuids || something(new, old).name in names)]
2947+
if filter
2948+
# Find packages matching the filter
2949+
matching_ids = Set{UUID}()
2950+
for (id, old, new) in xs
2951+
if (id in uuids || something(new, old).name in names)
2952+
push!(matching_ids, id)
2953+
end
2954+
end
2955+
# In manifest mode, also include all dependencies of matching packages
2956+
if manifest && !isempty(matching_ids)
2957+
deps_to_add = Set{UUID}()
2958+
for id in matching_ids
2959+
entry = get(env.manifest, id, nothing)
2960+
if entry !== nothing
2961+
union!(deps_to_add, values(entry.deps))
2962+
end
2963+
end
2964+
union!(matching_ids, deps_to_add)
2965+
end
2966+
xs = eltype(xs)[(id, old, new) for (id, old, new) in xs if id in matching_ids]
2967+
end
29482968
if isempty(xs)
29492969
printpkgstyle(
29502970
io, Symbol("No Matches"),

test/new.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2957,6 +2957,17 @@ end
29572957
@test any(l -> occursin(r"\[7876af07\] Example\s*v0\.3\.0", l), statuslines)
29582958
@test any(l -> occursin(r"\[2a0f44e3\] Base64", l), statuslines)
29592959
@test any(l -> occursin(r"\[d6f4376e\] Markdown", l), statuslines)
2960+
# Test that manifest status with filter shows package and its dependencies (issue #1989)
2961+
Pkg.add(name = "JSON", version = "0.21.0") # JSON has dependencies
2962+
Pkg.status("JSON"; io = io, mode = Pkg.PKGMODE_MANIFEST)
2963+
statuslines = readlines(io)
2964+
@test occursin(r"Status `.+Manifest.toml`", first(statuslines))
2965+
@test any(l -> occursin(r"\[682c06a0\] JSON\s*v0\.21\.0", l), statuslines)
2966+
# JSON's dependencies (Parsers, Dates, Mmap, Unicode) should also be shown
2967+
@test any(l -> occursin(r"Parsers", l), statuslines)
2968+
# But Example and Markdown (not dependencies of JSON) should not be shown
2969+
@test !any(l -> occursin(r"\[7876af07\] Example", l), statuslines)
2970+
@test !any(l -> occursin(r"\[d6f4376e\] Markdown", l), statuslines)
29602971
end
29612972
# Diff API
29622973
isolate(loaded_depot = true) do

0 commit comments

Comments
 (0)