Skip to content

Commit

Permalink
Fix status output for pin/free, fixes #1931 (#2446)
Browse files Browse the repository at this point in the history
(cherry picked from commit 91b6754)
  • Loading branch information
00vareladavid authored and IanButterworth committed Mar 27, 2021
1 parent 0561396 commit e09d23f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1744,12 +1744,14 @@ print_single(ctx::Context, pkg::PackageSpec) = printstyled(ctx.io, stat_rep(pkg)

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(ctx::Context, old::Union{Nothing,PackageSpec}, new::Union{Nothing,PackageSpec})
if !is_instantiated(old) && is_instantiated(new)
printstyled(ctx.io, "+ $(stat_rep(new))"; color=:light_green)
elseif !is_instantiated(new)
printstyled(ctx.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(ctx.io, "$(stat_rep(old))$(stat_rep(new; name=false))"; color=:light_yellow)
else
Expand Down
25 changes: 21 additions & 4 deletions test/new.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1914,11 +1914,28 @@ end
@test occursin(r"Updating `.+Manifest\.toml`", readline(io))
@test occursin(r"\[7876af07\] ~ Example v\d\.\d\.\d `https://github.com/JuliaLang/Example.jl.git#master` ⇒ v\d\.\d\.\d", readline(io))
# Removing registered version

Pkg.rm("Example"; status_io=io)
@test occursin(r"Updating `.+Project.toml`", readline(io))
@test occursin(r"\[7876af07\] - Example v\d\.\d\.\d", readline(io))
@test occursin(r"Updating `.+Manifest.toml`", readline(io))
@test occursin(r"\[7876af07\] - Example v\d\.\d\.\d", readline(io))
output = String(take!(io))
@test occursin(r"Updating `.+Project.toml`", output)
@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"; status_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"; status_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 e09d23f

Please sign in to comment.