Skip to content

Commit 30fa740

Browse files
00vareladavidKristofferC
authored andcommitted
Fix status output for pin/free, fixes #1931 (#2446)
(cherry picked from commit 91b6754)
1 parent af7e2c7 commit 30fa740

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

src/Operations.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1744,12 +1744,14 @@ print_single(ctx::Context, pkg::PackageSpec) = printstyled(ctx.io, stat_rep(pkg)
17441744

17451745
is_instantiated(::Nothing) = false
17461746
is_instantiated(x::PackageSpec) = x.version != VersionSpec() || is_stdlib(x.uuid)
1747+
# Compare an old and new node of the dependency graph and print a single line to summarize the change
17471748
function print_diff(ctx::Context, old::Union{Nothing,PackageSpec}, new::Union{Nothing,PackageSpec})
17481749
if !is_instantiated(old) && is_instantiated(new)
17491750
printstyled(ctx.io, "+ $(stat_rep(new))"; color=:light_green)
17501751
elseif !is_instantiated(new)
17511752
printstyled(ctx.io, "- $(stat_rep(old))"; color=:light_red)
1752-
elseif is_tracking_registry(old) && is_tracking_registry(new) && new.version isa VersionNumber && old.version isa VersionNumber
1753+
elseif is_tracking_registry(old) && is_tracking_registry(new) &&
1754+
new.version isa VersionNumber && old.version isa VersionNumber && new.version != old.version
17531755
if new.version > old.version
17541756
printstyled(ctx.io, "$(stat_rep(old))$(stat_rep(new; name=false))"; color=:light_yellow)
17551757
else

test/new.jl

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1914,11 +1914,28 @@ end
19141914
@test occursin(r"Updating `.+Manifest\.toml`", readline(io))
19151915
@test occursin(r"\[7876af07\] ~ Example v\d\.\d\.\d `https://github.com/JuliaLang/Example.jl.git#master` ⇒ v\d\.\d\.\d", readline(io))
19161916
# Removing registered version
1917+
19171918
Pkg.rm("Example"; status_io=io)
1918-
@test occursin(r"Updating `.+Project.toml`", readline(io))
1919-
@test occursin(r"\[7876af07\] - Example v\d\.\d\.\d", readline(io))
1920-
@test occursin(r"Updating `.+Manifest.toml`", readline(io))
1921-
@test occursin(r"\[7876af07\] - Example v\d\.\d\.\d", readline(io))
1919+
output = String(take!(io))
1920+
@test occursin(r"Updating `.+Project.toml`", output)
1921+
@test occursin(r"\[7876af07\] - Example v\d\.\d\.\d", output)
1922+
@test occursin(r"Updating `.+Manifest.toml`", output)
1923+
@test occursin(r"\[7876af07\] - Example v\d\.\d\.\d", output)
1924+
1925+
# Pinning a registered package
1926+
Pkg.add("Example")
1927+
Pkg.pin("Example"; status_io=io)
1928+
output = String(take!(io))
1929+
@test occursin(r"Updating `.+Project.toml`", output)
1930+
@test occursin(r"\[7876af07\] ~ Example v\d\.\d\.\d ⇒ v\d\.\d\.\d", output)
1931+
@test occursin(r"Updating `.+Manifest.toml`", output)
1932+
1933+
# Free a pinned package
1934+
Pkg.free("Example"; status_io=io)
1935+
output = String(take!(io))
1936+
@test occursin(r"Updating `.+Project.toml`", output)
1937+
@test occursin(r"\[7876af07\] ~ Example v\d\.\d\.\d ⚲ ⇒ v\d\.\d\.\d", output)
1938+
@test occursin(r"Updating `.+Manifest.toml`", output)
19221939
end
19231940
# Project Status API
19241941
isolate(loaded_depot=true) do

0 commit comments

Comments
 (0)