Skip to content

Commit

Permalink
Fix status output for pin/free, fixes JuliaLang#1931 (JuliaLang#2446)
Browse files Browse the repository at this point in the history
  • Loading branch information
00vareladavid authored Mar 23, 2021
1 parent 8250851 commit 91b6754
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1636,12 +1636,14 @@ print_single(io::IO, pkg::PackageSpec) = printstyled(io, stat_rep(pkg); color=:w

is_instantiated(::Nothing) = false
is_instantiated(x::PackageSpec) = x.version != VersionSpec() || is_stdlib(x.uuid)
# Compare an old and new node of the dependency graph and print a single line to summarize the change
function print_diff(io::IO, old::Union{Nothing,PackageSpec}, new::Union{Nothing,PackageSpec})
if !is_instantiated(old) && is_instantiated(new)
printstyled(io, "+ $(stat_rep(new))"; color=:light_green)
elseif !is_instantiated(new)
printstyled(io, "- $(stat_rep(old))"; color=:light_red)
elseif is_tracking_registry(old) && is_tracking_registry(new) && new.version isa VersionNumber && old.version isa VersionNumber
elseif is_tracking_registry(old) && is_tracking_registry(new) &&
new.version isa VersionNumber && old.version isa VersionNumber && new.version != old.version
if new.version > old.version
printstyled(io, "$(stat_rep(old))$(stat_rep(new; name=false))"; color=:light_yellow)
else
Expand Down
15 changes: 15 additions & 0 deletions test/new.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1954,6 +1954,21 @@ end
@test occursin(r"\[7876af07\] - Example v\d\.\d\.\d", output)
@test occursin(r"Updating `.+Manifest.toml`", output)
@test occursin(r"\[7876af07\] - Example v\d\.\d\.\d", output)

# Pinning a registered package
Pkg.add("Example")
Pkg.pin("Example"; io=io)
output = String(take!(io))
@test occursin(r"Updating `.+Project.toml`", output)
@test occursin(r"\[7876af07\] ~ Example v\d\.\d\.\d ⇒ v\d\.\d\.\d", output)
@test occursin(r"Updating `.+Manifest.toml`", output)

# Free a pinned package
Pkg.free("Example"; io=io)
output = String(take!(io))
@test occursin(r"Updating `.+Project.toml`", output)
@test occursin(r"\[7876af07\] ~ Example v\d\.\d\.\d ⚲ ⇒ v\d\.\d\.\d", output)
@test occursin(r"Updating `.+Manifest.toml`", output)
end
# Project Status API
isolate(loaded_depot=true) do
Expand Down

0 comments on commit 91b6754

Please sign in to comment.