Skip to content

Commit 9c8914e

Browse files
authored
Refactor pkg path-finding code for reusability (#37624)
Revise duplicates much of `explicit_manifest_uuid_path`, but there seems little value in having packages need to dive into the details of `version_slug` etc. This allows reactors it to make it easier for packages to rely on Base for this functionality.
1 parent 324194c commit 9c8914e

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

base/loading.jl

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -484,21 +484,26 @@ function explicit_manifest_uuid_path(project_file::String, pkg::PkgId, cache::TO
484484
uuid = get(entry, "uuid", nothing)::Union{Nothing, String}
485485
uuid === nothing && continue
486486
if UUID(uuid) === pkg.uuid
487-
path = get(entry, "path", nothing)::Union{Nothing, String}
488-
if path !== nothing
489-
path = normpath(abspath(dirname(manifest_file), path))
490-
return path
491-
end
492-
hash = get(entry, "git-tree-sha1", nothing)::Union{Nothing, String}
493-
hash === nothing && return nothing
494-
hash = SHA1(hash)
495-
# Keep the 4 since it used to be the default
496-
for slug in (version_slug(pkg.uuid, hash, 4), version_slug(pkg.uuid, hash))
497-
for depot in DEPOT_PATH
498-
path = abspath(depot, "packages", pkg.name, slug)
499-
ispath(path) && return path
500-
end
501-
end
487+
return explicit_manifest_entry_path(manifest_file, pkg, entry)
488+
end
489+
end
490+
return nothing
491+
end
492+
493+
function explicit_manifest_entry_path(manifest_file::String, pkg::PkgId, entry::Dict{String,Any})
494+
path = get(entry, "path", nothing)::Union{Nothing, String}
495+
if path !== nothing
496+
path = normpath(abspath(dirname(manifest_file), path))
497+
return path
498+
end
499+
hash = get(entry, "git-tree-sha1", nothing)::Union{Nothing, String}
500+
hash === nothing && return nothing
501+
hash = SHA1(hash)
502+
# Keep the 4 since it used to be the default
503+
for slug in (version_slug(pkg.uuid, hash, 4), version_slug(pkg.uuid, hash))
504+
for depot in DEPOT_PATH
505+
path = abspath(depot, "packages", pkg.name, slug)
506+
ispath(path) && return path
502507
end
503508
end
504509
return nothing

0 commit comments

Comments
 (0)