Skip to content
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "RegistryTools"
uuid = "d1eb7eb1-105f-429d-abf5-b0f65cb9e2c4"
authors = ["Stefan Karpinski <[email protected]>"]
version = "2.4.1"
version = "2.4.2"

[deps]
LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433"
Expand Down
15 changes: 13 additions & 2 deletions src/Compress.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,28 @@ function compress(path::AbstractString, uncompressed::Dict,
inverted = Dict{Pair{String,Any},Vector{VersionNumber}}()
for (ver, data) in uncompressed, (key, val) in data
val isa Base.UUID && (val = string(val))
push!(get!(inverted, key => val, VersionNumber[]), ver)
push!(get!(inverted, key => unspace_hyphen(val), VersionNumber[]), ver)
end
compressed = Dict{String,Dict{String,Any}}()
for ((k, v), vers) in inverted
for r in compress_versions(versions, sort!(vers)).ranges
get!(compressed, string(r), Dict{String,Any}())[k] = v
get!(compressed, unspace_hyphen(string(r)), Dict{String, Any}())[k] = v
end
end
return compressed
end

# Existing version ranges in `Compat.toml` files are stored without spaces
# around hyphens. New version ranges are added with spaces in their string
# representation. Remove all spaces, so that equal version ranges compare
# equal as strings. This is a temporary work-around that will become
# unnecessary when "all this is rewritten to use VersionNumbers", as
# suggested above.
#
# The source of the spaces is https://github.com/JuliaLang/Pkg.jl/pull/3580.
unspace_hyphen(x::AbstractString) = replace(x, " - " => "-")
unspace_hyphen(x::AbstractVector) = unspace_hyphen.(x)

function save(path::AbstractString, uncompressed::Dict,
versions::Vector{VersionNumber} = load_versions(path))
compressed = compress(path, uncompressed)
Expand Down
Loading