Repository navigation
Expand file tree
/
Copy pathcheck.jl
More file actions
51 lines (43 loc) · 1.6 KB
/
Copy pathcheck.jl
File metadata and controls
51 lines (43 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Structural consistency check for the registry. No dependencies beyond TOML.
using TOML
failures = String[]
fail(msg) = push!(failures, msg)
index = TOML.parsefile("Registry.toml")
for key in ("name", "uuid", "repo")
haskey(index, key) || fail("Registry.toml missing `$key`")
end
for (uuid, entry) in get(index, "packages", Dict{String,Any}())
path = entry["path"]
prefix = "$(entry["name"]) ($path):"
isdir(path) || (fail("$prefix directory missing"); continue)
package = TOML.parsefile(joinpath(path, "Package.toml"))
package["name"] == entry["name"] || fail("$prefix Package.toml name mismatch")
package["uuid"] == uuid || fail("$prefix Package.toml uuid mismatch")
haskey(package, "repo") || fail("$prefix Package.toml missing repo")
versions = TOML.parsefile(joinpath(path, "Versions.toml"))
isempty(versions) && fail("$prefix no versions")
for (v, info) in versions
tree = get(info, "git-tree-sha1", "")
occursin(r"^[0-9a-f]{40}$", tree) || fail("$prefix $v bad git-tree-sha1")
try
VersionNumber(v)
catch
fail("$prefix $v is not a valid version number")
end
end
for file in ("Deps.toml", "Compat.toml")
full = joinpath(path, file)
isfile(full) && try
TOML.parsefile(full)
catch e
fail("$prefix $file does not parse: $e")
end
end
end
if isempty(failures)
n = length(get(index, "packages", Dict()))
println("Registry consistent ($n packages)")
else
foreach(println, failures)
error("$(length(failures)) consistency failure(s)")
end