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
7 changes: 6 additions & 1 deletion src/Types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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])]" :
Expand Down
2 changes: 2 additions & 0 deletions test/new.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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