From 4f62568d1608b90edaf09435a1b16e75d499496e Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Mon, 18 Nov 2024 16:35:03 -0500 Subject: [PATCH 1/4] Automatically upgrade empty manifest files to v2 format --- src/manifest.jl | 6 +++++- test/manifests.jl | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/manifest.jl b/src/manifest.jl index 2fc95023ca..94509aedae 100644 --- a/src/manifest.jl +++ b/src/manifest.jl @@ -219,7 +219,11 @@ function read_manifest(f_or_io::Union{String, IO}) rethrow() end if Base.is_v1_format_manifest(raw) - raw = convert_v1_format_manifest(raw) + if isempty(raw) # treat an empty Manifest file as v2 format for convenience + raw["manifest_format"] => "2.0.0" + else + raw = convert_v1_format_manifest(raw) + end end return Manifest(raw, f_or_io) end diff --git a/test/manifests.jl b/test/manifests.jl index 32ffcf3ba4..dfc616deba 100644 --- a/test/manifests.jl +++ b/test/manifests.jl @@ -44,6 +44,21 @@ end end end + @testset "Empty manifest file is automatically upgraded to v2" begin + isolate(loaded_depot=true) do + io = IOBuffer() + d = mktempdir() + manifest = joinpath(d, "Manifest.toml") + touch(manifest) + Pkg.activate(d; io=io) + output = String(take!(io)) + @test occursin(r"Activating.*project at.*", output) + env_manifest = Pkg.Types.Context().env.manifest_file + @test Base.is_v1_format_manifest(Base.parsed_toml(env_manifest)) == true + @test Pkg.Types.Context().env.manifest.manifest_format == v"2.0.0" + end + end + @testset "v1.0: activate, change, maintain manifest format" begin reference_manifest_isolated_test("v1.0", v1 = true) do env_dir, env_manifest io = IOBuffer() From 3edebaa2c184de84ccc9bcebb6e88ad881acd400 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Mon, 18 Nov 2024 17:47:29 -0500 Subject: [PATCH 2/4] Update manifest.jl --- src/manifest.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/manifest.jl b/src/manifest.jl index 94509aedae..db04bdbe7f 100644 --- a/src/manifest.jl +++ b/src/manifest.jl @@ -220,7 +220,7 @@ function read_manifest(f_or_io::Union{String, IO}) end if Base.is_v1_format_manifest(raw) if isempty(raw) # treat an empty Manifest file as v2 format for convenience - raw["manifest_format"] => "2.0.0" + raw["manifest_format"] = "2.0.0" else raw = convert_v1_format_manifest(raw) end From 812cd4f6fc3216733b415feacbe01d0710cdf413 Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Tue, 19 Nov 2024 11:40:07 -0500 Subject: [PATCH 3/4] expand tests --- test/manifests.jl | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/test/manifests.jl b/test/manifests.jl index dfc616deba..e045bd29ca 100644 --- a/test/manifests.jl +++ b/test/manifests.jl @@ -54,8 +54,22 @@ end output = String(take!(io)) @test occursin(r"Activating.*project at.*", output) env_manifest = Pkg.Types.Context().env.manifest_file - @test Base.is_v1_format_manifest(Base.parsed_toml(env_manifest)) == true + @test env_manifest == manifest + # an empty manifest is still technically considered to be v1 manifest + @test Base.is_v1_format_manifest(Base.parsed_toml(env_manifest)) + @test Pkg.Types.Context().env.manifest.manifest_format == v"2.0.0" + + Pkg.add("Profile"; io=io) + env_manifest = Pkg.Types.Context().env.manifest_file + @test env_manifest == manifest + @test Base.is_v1_format_manifest(Base.parsed_toml(env_manifest)) == false @test Pkg.Types.Context().env.manifest.manifest_format == v"2.0.0" + + # check that having a Project with deps, and an empty manifest file doesn't error + rm(manifest) + touch(manifest) + Pkg.activate(d; io=io) + Pkg.add("Example"; io=io) end end From 183fc359513201767d86c5aeda97f9f0401cf61d Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Wed, 20 Nov 2024 09:28:11 -0500 Subject: [PATCH 4/4] fix tests --- test/manifests.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/manifests.jl b/test/manifests.jl index e045bd29ca..a1780673d1 100644 --- a/test/manifests.jl +++ b/test/manifests.jl @@ -54,14 +54,14 @@ end output = String(take!(io)) @test occursin(r"Activating.*project at.*", output) env_manifest = Pkg.Types.Context().env.manifest_file - @test env_manifest == manifest + @test samefile(env_manifest, manifest) # an empty manifest is still technically considered to be v1 manifest @test Base.is_v1_format_manifest(Base.parsed_toml(env_manifest)) @test Pkg.Types.Context().env.manifest.manifest_format == v"2.0.0" Pkg.add("Profile"; io=io) env_manifest = Pkg.Types.Context().env.manifest_file - @test env_manifest == manifest + @test samefile(env_manifest, manifest) @test Base.is_v1_format_manifest(Base.parsed_toml(env_manifest)) == false @test Pkg.Types.Context().env.manifest.manifest_format == v"2.0.0"