diff --git a/src/Types.jl b/src/Types.jl index 96f951434f..2b475d4b10 100644 --- a/src/Types.jl +++ b/src/Types.jl @@ -85,7 +85,8 @@ end Base.:(==)(r1::GitRepo, r2::GitRepo) = r1.source == r2.source && r1.rev == r2.rev && r1.subdir == r2.subdir - +Base.hash(r::GitRepo, h::UInt) = + foldr(hash, [r.source, r.rev, r.subdir], init=h) mutable struct PackageSpec name::Union{Nothing,String} @@ -119,11 +120,15 @@ PackageSpec(name::AbstractString, uuid::UUID) = PackageSpec(;name=name, uuid=uui PackageSpec(name::AbstractString, version::VersionTypes) = PackageSpec(;name=name, version=version)::PackageSpec PackageSpec(n::AbstractString, u::UUID, v::VersionTypes) = PackageSpec(;name=n, uuid=u, version=v)::PackageSpec +# XXX: These definitions are a bit fishy. It seems to be used in an `==` call in status printing function Base.:(==)(a::PackageSpec, b::PackageSpec) return a.name == b.name && a.uuid == b.uuid && a.version == b.version && a.tree_hash == b.tree_hash && a.repo == b.repo && a.path == b.path && a.pinned == b.pinned end +function Base.hash(a::PackageSpec, h::UInt) + return foldr(hash, [a.name, a.uuid, a.version, a.tree_hash, a.repo, a.path, a.pinned], init=h) +end function err_rep(pkg::PackageSpec) x = pkg.name !== nothing && pkg.uuid !== nothing ? x = "$(pkg.name) [$(string(pkg.uuid)[1:8])]" : diff --git a/test/new.jl b/test/new.jl index 8b4f4c3bc1..1554711267 100644 --- a/test/new.jl +++ b/test/new.jl @@ -3280,4 +3280,6 @@ end @test occursin("[loaded: v0.5.4]", out) end +@test allunique(unique([Pkg.PackageSpec(path="foo"), Pkg.PackageSpec(path="foo")])) + end #module