Skip to content

Commit

Permalink
Read in Package.toml and add "repo" to PkgEntry (JuliaEcosystem#31)
Browse files Browse the repository at this point in the history
* Read in Package.toml and add "repo" to PkgEntry

* Add missing Dep, fix tests, remove try/catch

* Bump version

* Add DownDep to test README
  • Loading branch information
fchorney authored May 13, 2021
1 parent 0332424 commit 27d072d
Show file tree
Hide file tree
Showing 15 changed files with 43 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "PkgDeps"
uuid = "839e9fc8-855b-5b3c-a3b7-2833d3dd1f59"
license = "MIT"
version = "0.6.0"
version = "0.6.1"

[deps]
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
Expand Down
1 change: 1 addition & 0 deletions src/pkg_entry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ struct PkgEntry
registry_path::String
name::String
uuid::UUID
repo::String
end
7 changes: 5 additions & 2 deletions src/registry_instance.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ function RegistryInstance(path::AbstractString)

for (uuid, info) in d["packages"]
uuid = UUID(uuid)
info
name = info["name"]
pkgpath = info["path"]
pkg = PkgEntry(pkgpath, path, name, uuid)

p = parsefile(joinpath(path, pkgpath, "Package.toml"))
p_repo = p["repo"]

pkg = PkgEntry(pkgpath, path, name, uuid, p_repo)
pkgs[name] = pkg
end

Expand Down
3 changes: 3 additions & 0 deletions test/resources/registries/Foobar/Case1/Package.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name = "Case1"
uuid = "00000000-1111-2222-3333-444444444444"
repo = "https://path.to.repo/"
3 changes: 3 additions & 0 deletions test/resources/registries/Foobar/Case2/Package.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name = "Case2"
uuid = "a2a98da0-c97c-48ea-aa95-967bbb6a44f4"
repo = "https://path.to.repo/"
3 changes: 3 additions & 0 deletions test/resources/registries/Foobar/ClashPkg/Package.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name = "ClashPkg"
uuid = "6402c8d7-2ba1-4f69-b0bd-e6ec13832549"
repo = "https://path.to.repo/"
3 changes: 3 additions & 0 deletions test/resources/registries/Foobar/ClashUser1/Package.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name = "ClashUser1"
uuid = "a457e2d6-f3f7-45f3-9559-ce8bafa0c916"
repo = "https://path.to.repo/"
2 changes: 2 additions & 0 deletions test/resources/registries/Foobar/DownDep/Deps.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[0]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
3 changes: 3 additions & 0 deletions test/resources/registries/Foobar/DownDep/Package.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name = "DownDep"
uuid = "000eeb74-f857-587a-a816-be5685e97e75"
repo = "https://path.to.repo/"
2 changes: 2 additions & 0 deletions test/resources/registries/Foobar/DownDep/Versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
["0.0.1"]
git-tree-sha1 = "7bbdd841302ae0708824fa57d77a3e4780097531"
3 changes: 3 additions & 0 deletions test/resources/registries/General/Case3/Package.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name = "Case3"
uuid = "40783f5b-986f-4943-913a-db8b00df110d"
repo = "https://path.to.repo/"
3 changes: 3 additions & 0 deletions test/resources/registries/General/Case4/Package.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name = "Case4"
uuid = "172f9e6e-38ba-42e1-abf1-05c2c32c0454"
repo = "https://path.to.repo/"
3 changes: 3 additions & 0 deletions test/resources/registries/General/ClashPkg/Package.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name = "ClashPkg"
uuid = "39dceb45-186c-466b-9eef-57dbb7902773"
repo = "https://path.to.repo/"
4 changes: 4 additions & 0 deletions test/resources/registries/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ The version in `Foobar` depends on `Case2`, while the version in General depends
## ClashUser1

This package uses the `ClashPkg` registered in `Foobar`.

## DownDep

This package is registered in `Foobar`
6 changes: 4 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,12 @@ all_registries = reachable_registries(; depots=DEPOT)
entry = PkgDeps._find_latest_pkg_entry("ClashPkg"; registries=all_registries)
# General has a later version of `ClashPkg`
@test entry.uuid == clashpkg_general_uuid
@test entry.repo == "https://path.to.repo/"

# No conflict here, so it should just find the right one
entry = PkgDeps._find_latest_pkg_entry("Case4"; registries=all_registries)
@test entry.uuid == UUID("172f9e6e-38ba-42e1-abf1-05c2c32c0454")
@test entry.repo == "https://path.to.repo/"

entry = PkgDeps._find_latest_pkg_entry(missing, UUID("172f9e6e-38ba-42e1-abf1-05c2c32c0454"); registries=all_registries)
@test entry.name == "Case4"
Expand Down Expand Up @@ -138,8 +140,8 @@ end

@testset "`dependencies`" begin
deps_foo = dependencies("ClashPkg"; registries=[FOOBAR_REGISTRY])
@test length(deps_foo) == 3
@test Set(["Statistics", "DownDep", "Case2"]) == Set(keys(deps_foo))
@test length(deps_foo) == 4
@test Set(["Statistics", "Test", "DownDep", "Case2"]) == Set(keys(deps_foo))

# alternatively, use the UUID. Can allow all registries here, since the UUID specifies exactly.
@test deps_foo == dependencies(clashpkg_foobar_uuid; registries=all_registries)
Expand Down

0 comments on commit 27d072d

Please sign in to comment.