Skip to content

Commit

Permalink
Check that a registry has the correct versions of stripped packages
Browse files Browse the repository at this point in the history
This handles cases where a package has migrated between registries, such as
moving from a closed source registry to the General registry. Only accept the
registry metadata if there is a matching version.
  • Loading branch information
MichaelHatherly committed May 3, 2024
1 parent 929a8a4 commit a5f240e
Showing 1 changed file with 25 additions and 14 deletions.
39 changes: 25 additions & 14 deletions src/code_stripping.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,28 +153,39 @@ function _generate_stripped_registry(;
found = false
for reg in registries
if haskey(reg, package_uuid)
found = true

info = get!(() -> _process_reg_info(reg), registry_info, reg.uuid)
pkg_entry = reg[package_uuid]
pkg_path = pkg_entry.path

stripped_info = get!(Dict, registry_contents, pkg_path)
for (k, v) in info[pkg_path]
k == "Versions.toml" && continue
stripped_info[k] = v
end
# Package versions may be split across multiple registries
# if they have been migrated from closed source to open, for
# example. We verify that the registry we're currently
# looking through has the package version that we want.
if haskey(
get(Dict{String,Any}, info[pkg_path], "Versions.toml"),
version,
)
found = true

versions_toml = get!(Dict{String,Any}, stripped_info, "Versions.toml")
versions_toml[version] = Dict{String,Any}("git-tree-sha1" => tree_hash)
stripped_info = get!(Dict, registry_contents, pkg_path)
for (k, v) in info[pkg_path]
k == "Versions.toml" && continue
stripped_info[k] = v
end

project_toml = get!(Dict{String,Any}, stripped_info, "Package.toml")
project_toml["repo"] = "{{PACKAGES}}/$package_name"
versions_toml =
get!(Dict{String,Any}, stripped_info, "Versions.toml")
versions_toml[version] =
Dict{String,Any}("git-tree-sha1" => tree_hash)

packages[string(package_uuid)] =
Dict("name" => pkg_entry.name, "path" => pkg_path)
project_toml = get!(Dict{String,Any}, stripped_info, "Package.toml")
project_toml["repo"] = "{{PACKAGES}}/$package_name"

break
packages[string(package_uuid)] =
Dict("name" => pkg_entry.name, "path" => pkg_path)

break
end
end
end
if !found
Expand Down

0 comments on commit a5f240e

Please sign in to comment.