Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more repo metadata #152

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
43 changes: 28 additions & 15 deletions src/metadata.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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.")

Expand All @@ -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
32 changes: 32 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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]
)
]

Expand Down Expand Up @@ -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"
Expand Down