Skip to content

Commit

Permalink
bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Doris committed Mar 30, 2022
1 parent fb01066 commit 80e8576
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
15 changes: 11 additions & 4 deletions src/meta.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ This file defines functions to interact with the `.CondaPkg/meta` file which rec
information about the most recent resolve.
"""

const META_VERSION = 5 # increment whenever the metadata format changes
const META_VERSION = 6 # increment whenever the metadata format changes

@kwdef mutable struct Meta
timestamp::Float64
Expand Down Expand Up @@ -52,13 +52,19 @@ function read_meta(io::IO, ::Type{VersionNumber})
VersionNumber(read_meta(io, String))
end
function read_meta(io::IO, ::Type{PkgSpec})
PkgSpec(read_meta(io, String), version = read_meta(io, String))
name = read_meta(io, String)
version = read_meta(io, String)
channel = read_meta(io, String)
PkgSpec(name, version=version, channel=channel)
end
function read_meta(io::IO, ::Type{ChannelSpec})
ChannelSpec(read_meta(io, String))
name = read_meta(io, String)
ChannelSpec(name)
end
function read_meta(io::IO, ::Type{PipPkgSpec})
PipPkgSpec(read_meta(io, String), version = read_meta(io, String))
name = read_meta(io, String)
version = read_meta(io, String)
PipPkgSpec(name, version=version)
end

function write_meta(io::IO, meta::Meta)
Expand Down Expand Up @@ -91,6 +97,7 @@ end
function write_meta(io::IO, x::PkgSpec)
write_meta(io, x.name)
write_meta(io, x.version)
write_meta(io, x.channel)
end
function write_meta(io::IO, x::ChannelSpec)
write_meta(io, x.name)
Expand Down
4 changes: 2 additions & 2 deletions src/resolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,10 @@ function resolve(; force::Bool=false, io::IO=stderr, interactive::Bool=false, dr
if meta === nothing
removed_pkgs = String[]
changed_pkgs = String[]
added_pkgs = specs
added_pkgs = unique!(String[x.name for x in specs])
removed_pip_pkgs = String[]
changed_pip_pkgs = String[]
added_pip_pkgs = pip_specs
added_pip_pkgs = unique!(String[x.name for x in pip_specs])
else
removed_pkgs, changed_pkgs, added_pkgs = _resolve_diff(meta.packages, specs)
removed_pip_pkgs, changed_pip_pkgs, added_pip_pkgs = _resolve_pip_diff(meta.pip_packages, pip_specs)
Expand Down
18 changes: 18 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,24 @@ const isnull = backend == "Null"
@test spec.version == "@./SOME/Path"
end

@testset "meta IO" begin
specs = Any[
CondaPkg.PkgSpec("foo", version="=1.2.3", channel="bar"),
CondaPkg.ChannelSpec("fooo"),
CondaPkg.PipPkgSpec("foooo", version="==2.3.4")
]
for spec in specs
io = IOBuffer()
CondaPkg.write_meta(io, spec)
seekstart(io)
spec2 = CondaPkg.read_meta(io, typeof(spec))
@test spec == spec2
for k in propertynames(spec)
@test getproperty(spec, k) == getproperty(spec2, k)
end
end
end

@testset "abspathurl" begin
@test startswith(CondaPkg.abspathurl("foo"), "file://")
@test endswith(CondaPkg.abspathurl("foo"), "/foo")
Expand Down

0 comments on commit 80e8576

Please sign in to comment.