Skip to content

Ensure that string(::VersionSpec) is compatible with semver_spec() #3580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 28, 2023
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
6 changes: 3 additions & 3 deletions src/Versions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,15 @@ function Base.print(io::IO, r::VersionRange)
if (m, n) == (0, 0)
print(io, '*')
elseif m == 0
print(io, "0-")
print(io, "0 -")
join(io, r.upper.t, '.')
elseif n == 0
join(io, r.lower.t, '.')
print(io, "-*")
print(io, " - *")
else
join(io, r.lower.t[1:m], '.')
if r.lower != r.upper
print(io, '-')
print(io, " - ")
join(io, r.upper.t[1:n], '.')
end
end
Expand Down
3 changes: 2 additions & 1 deletion test/pkg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ import Pkg.Types: semver_spec, VersionSpec
@test !(v"0.3" in semver_spec("0.1 - 0.2"))
@test v"0.2.99" in semver_spec("0.1 - 0.2")
@test v"0.3" in semver_spec("0.1 - 0")
@test semver_spec(string(VersionSpec("1-2"))) == VersionSpec("1-2")

@test_throws ErrorException semver_spec("^^0.2.3")
@test_throws ErrorException semver_spec("^^0.2.3.4")
Expand All @@ -152,7 +153,7 @@ end

# TODO: Should rewrite these tests not to rely on internals like field names
@testset "union, isjoinable" begin
@test sprint(print, VersionRange("0-0.3.2")) == "0-0.3.2"
@test sprint(print, VersionRange("0-0.3.2")) == "0 - 0.3.2"
# test missing paths on union! and isjoinable
# there's no == for VersionBound or VersionRange
unified_vr = union!([VersionRange("1.5-2.8"), VersionRange("2.5-3")])[1]
Expand Down