Skip to content

Commit fa7e82a

Browse files
New Manifest.toml format: Don't write julia_version to manifest if nothing (#2612)
* don't write julia_version to manifest if nothing (cherry picked from commit b2b215e)
1 parent d69a8a0 commit fa7e82a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/manifest.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ function validate_manifest(julia_version::Union{Nothing,VersionNumber}, manifest
129129
end
130130

131131
function Manifest(raw::Dict, f_or_io::Union{String, IO})::Manifest
132-
julia_version = raw["julia_version"] == "nothing" ? nothing : VersionNumber(raw["julia_version"])
132+
julia_version = haskey(raw, "julia_version") ? VersionNumber(raw["julia_version"]) : nothing
133133
manifest_format = VersionNumber(raw["manifest_format"])
134134
if !in(manifest_format.major, 1:2)
135135
if f_or_io isa IO
@@ -203,16 +203,16 @@ function read_manifest(f_or_io::Union{String,IO})
203203
pkgerror("Could not parse manifest: ", sprint(showerror, raw))
204204
end
205205
if is_v1_format_manifest(raw)
206-
raw = convert_flat_format_manifest(raw)
206+
raw = convert_v1_format_manifest(raw)
207207
end
208208
return Manifest(raw, f_or_io)
209209
end
210210

211-
function convert_flat_format_manifest(old_raw_manifest::Dict)
211+
function convert_v1_format_manifest(old_raw_manifest::Dict)
212212
new_raw_manifest = Dict{String, Any}(
213213
"deps" => old_raw_manifest,
214-
"julia_version" => "nothing", # must be a string here to match raw dict
215214
"manifest_format" => "1.0.0" # must be a string here to match raw dict
215+
# don't set julia_version as it is unknown in old manifests
216216
)
217217
return new_raw_manifest
218218
end
@@ -239,7 +239,9 @@ function destructure(manifest::Manifest)::Dict
239239
raw = Dict{String,Vector{Dict{String,Any}}}()
240240
elseif manifest.manifest_format.major == 2
241241
raw = Dict{String,Any}()
242-
raw["julia_version"] = manifest.julia_version
242+
if !isnothing(manifest.julia_version) # don't write julia_version if nothing
243+
raw["julia_version"] = manifest.julia_version
244+
end
243245
raw["manifest_format"] = string(manifest.manifest_format.major, ".", manifest.manifest_format.minor)
244246
raw["deps"] = Dict{String,Vector{Dict{String,Any}}}()
245247
for (k, v) in manifest.other

0 commit comments

Comments
 (0)