Skip to content

Instantly share code, notes, and snippets.

@gdalle
Created September 1, 2022 13:53
Show Gist options
  • Save gdalle/1515fa51b58844985d0f50e9b3a7d0e1 to your computer and use it in GitHub Desktop.
Save gdalle/1515fa51b58844985d0f50e9b3a7d0e1 to your computer and use it in GitHub Desktop.
Counting stars for Julia packages
using CSV
using GitHub
using Pkg
using ProgressMeter
using TOML
myauth = GitHub.authenticate(ENV["GITHUB_AUTH"])
general = first(reg for reg in Pkg.Registry.reachable_registries() if reg.name == "General")
package_url = Dict{String,String}()
@showprogress for (toml_name, toml_file) in pairs(general.in_memory_registry)
if endswith(toml_name, "Package.toml")
package_info = TOML.parse(toml_file)
package_url[package_info["name"]] = package_info["repo"]
end
end
package_stars = Dict{String,Int}()
@showprogress for (name, url) in pairs(package_url)
trimmed_url = replace(url, "https://github.com/" => "", r".git$" => "")
try
package_stars[name] = length(stargazers(trimmed_url, auth=myauth)[1])
catch e
@info "Repo not retrieved" trimmed_url
end
end
CSV.write("stars.csv", package_stars)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment