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

Automatically upgrade empty manifest files to v2 format #4091

Merged
merged 4 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion src/manifest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 29 additions & 0 deletions test/manifests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,35 @@ 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 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 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"

# 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

@testset "v1.0: activate, change, maintain manifest format" begin
reference_manifest_isolated_test("v1.0", v1 = true) do env_dir, env_manifest
io = IOBuffer()
Expand Down
Loading