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

why: show all paths when package is both a direct and indirect dep #3771

Merged
merged 1 commit into from
Jan 30, 2024
Merged
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
26 changes: 12 additions & 14 deletions src/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2154,30 +2154,28 @@ function why(ctx::Context, pkgs::Vector{PackageSpec}; io::IO, kwargs...)

function find_paths!(final_paths, current, path = UUID[])
push!(path, current)
if !(current in values(ctx.env.project.deps))
for p in incoming[current]
if p in path
# detected dependency cycle and none of the dependencies in the cycle
# are in the project could happen when manually modifying
# the project and running this function function before a
# resolve
continue
end
find_paths!(final_paths, p, copy(path))
current in values(ctx.env.project.deps) && push!(final_paths, path) # record once we've traversed to a project dep
haskey(incoming, current) || return # but only return if we've reached a leaf that nothing depends on
for p in incoming[current]
if p in path
# detected dependency cycle and none of the dependencies in the cycle
# are in the project could happen when manually modifying
# the project and running this function function before a
# resolve
continue
end
else
push!(final_paths, path)
find_paths!(final_paths, p, copy(path))
end
end

first = true
for pkg in pkgs
!first && println(io)
first = false
final_paths = []
final_paths = Set{Vector{UUID}}()
find_paths!(final_paths, pkg.uuid)
foreach(reverse!, final_paths)
final_paths_names = map(x -> [ctx.env.manifest[uuid].name for uuid in x], final_paths)
final_paths_names = map(x -> [ctx.env.manifest[uuid].name for uuid in x], collect(final_paths))
sort!(final_paths_names, by = x -> (x, length(x)))
delimiter = sprint((io, args) -> printstyled(io, args...; color=:light_green), "→", context=io)
for path in final_paths_names
Expand Down
Loading