Skip to content

Commit

Permalink
support new manifest format during code load
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth committed May 30, 2021
1 parent 8402463 commit a73d60f
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -498,12 +498,31 @@ function explicit_project_deps_get(project_file::String, name::String)::Union{No
return nothing
end

# returns a deps list for both old and new manifest formats
function get_deps(raw_manifest::Dict)
if haskey(raw_manifest, "manifest_format")
if raw_manifest["manifest_format"] isa Dict && haskey(raw_manifest["manifest_format"], "uuid")
# the off-chance where an old format manifest has a dep called "manifest_format"
return raw_manifest
end
if haskey(raw_manifest, "deps")
return raw_manifest["deps"]
else
# if there are no deps then the `deps` field isn't present so return an empty dict
return Dict{String, Any}()
end
else
# older flat version manifest, return the entire dict
return raw_manifest
end
end

# find `where` stanza and return the PkgId for `name`
# return `nothing` if it did not find `where` (indicating caller should continue searching)
function explicit_manifest_deps_get(project_file::String, where::UUID, name::String)::Union{Nothing,PkgId}
manifest_file = project_file_manifest_path(project_file)
manifest_file === nothing && return nothing # manifest not found--keep searching LOAD_PATH
d = parsed_toml(manifest_file)
d = get_deps(parsed_toml(manifest_file))
found_where = false
found_name = false
for (dep_name, entries) in d
Expand Down Expand Up @@ -551,7 +570,7 @@ function explicit_manifest_uuid_path(project_file::String, pkg::PkgId)::Union{No
manifest_file = project_file_manifest_path(project_file)
manifest_file === nothing && return nothing # no manifest, skip env

d = parsed_toml(manifest_file)
d = get_deps(parsed_toml(manifest_file))
entries = get(d, pkg.name, nothing)::Union{Nothing, Vector{Any}}
entries === nothing && return nothing # TODO: allow name to mismatch?
for entry in entries
Expand Down

0 comments on commit a73d60f

Please sign in to comment.