diff --git a/src/metadata.jl b/src/metadata.jl index a1b726bc..6c5990c7 100644 --- a/src/metadata.jl +++ b/src/metadata.jl @@ -48,17 +48,21 @@ function update_metadata(packagespec, url, repo_owner, repo_name) end @info("Querying metadata.") + meta["metadata_error"] = false try gh_auth = authenticate(readchomp(authpath)) - repo_info = repo(repo_owner * "/" * repo_name, auth = gh_auth) - meta["description"] = something(repo_info.description, "") - meta["stargazers_count"] = something(repo_info.stargazers_count, 0) - meta["homepage"] = something(repo_info.homepage, 0) - topics_dict, page = topics(repo_info, auth = gh_auth) - meta["tags"] = something(topics_dict["names"], []) - meta["contributors"] = contributor_user.(contributors(repo_info, auth = gh_auth)[1]) + repo = repo_owner * "/" * repo_name + repo_info = repo_dict(repo, auth = gh_auth) + meta["description"] = something(repo_info["description"], "") + meta["archived"] = something(repo_info["archived"], false) + meta["private"] = something(repo_info["private"], false) + meta["stargazers_count"] = something(repo_info["stargazers_count"], 0) + meta["homepage"] = something(repo_info["homepage"], 0) + meta["tags"] = topics(repo, auth = gh_auth) + meta["contributors"] = contributors_dict(repo, auth = gh_auth) catch err - @error(string("Couldn't get info for ", url), error = err) + meta["metadata_error"] = true + @error(string("Couldn't get info for ", url), exception = (err, catch_backtrace())) end @info("Done querying metadata.") @@ -67,15 +71,24 @@ end function contributor_user(dict) Dict( - "name" => dict["contributor"].login, - "type" => dict["contributor"].typ, - "url" => string(dict["contributor"].html_url), + "name" => dict["login"], + "type" => dict["type"], + "url" => dict["html_url"], "contributions" => dict["contributions"] ) end -function topics(repo, api = GitHub.DEFAULT_API; options...) - results, page_data = GitHub.gh_get_paged_json(api, "/repos/$(GitHub.name(repo))/topics"; - headers = Dict("Accept" => "application/vnd.github.mercy-preview+json"), options...) - return results, page_data +function topics(name, api = GitHub.DEFAULT_API; options...) + return GitHub.gh_get_json(api, "/repos/$(name)/topics"; + headers = Dict( + "Accept" => "application/vnd.github.mercy-preview+json" + ), options...)["names"] end + +function repo_dict(name, api = GitHub.DEFAULT_API; options...) + return GitHub.gh_get_json(api, string("/repos/", name); options...) +end + +function contributors_dict(name, api = GitHub.DEFAULT_API; options...) + return contributor_user.(GitHub.gh_get_json(api, "/repos/$(name)/contributors"; options...)) +end \ No newline at end of file diff --git a/test/runtests.jl b/test/runtests.jl index 0cd49595..05192e40 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -242,6 +242,26 @@ end success = [true], doctype = ["documenter"], using_failed = [false] + ), + ( + name = "Gumbo", + url = "https://github.com/JuliaWeb/Gumbo.jl.git", + uuid = "708ec375-b3d6-5a57-a7ce-8257bf98657a", + versions = [v"0.8.0"], + installs = [true], + success = [true], + doctype = ["fallback_autodocs"], + using_failed = [false] + ), + ( + name = "Graphs", + url = "https://github.com/JuliaAttic/Graphs.jl.git", + uuid = "86223c79-3864-5bf0-83f7-82e725a168b6", + versions = [v"0.10.3"], + installs = [true], + success = [true], + doctype = ["fallback_autodocs"], + using_failed = [false] ) ] @@ -299,6 +319,18 @@ end if haskey(pkg, :using_failed) @test pkg.using_failed[i] == toml["using_failed"] end + + @test toml["metadata_error"] == false + + if pkg.name == "Graphs" + # properly mark archived packages + @test toml["archived"] == true + @test length(toml["contributors"]) > 0 + end + if pkg.name == "Zygote" + # properly mark archived packages + @test length(toml["tags"]) > 0 + end end if pkg.name == "Crayons"