Is there some way to go from the name of a package in the current environment, to the GitHub repo that it ultimately came from? I mean in the case of a package that is currently coming from a registry, not one that is explicitly specified as a repo in an add or dev.
Clearly Pkg at some point works this out when you do an add or update, and I wonder if it’s possible to hook into whatever it’s doing. If the API already has something for this I’ve missed it somehow.
The motivation is that I’d like to explore making some tooling to extract useful info from a given package’s repo, without priori knowing what that repo is.
rr = reachable_registries()
for reg_instance in rr
for pkg in reg_instance.pkgs
if pkg.second.name == pkgname
found = true
ri = registry_info(pkg.second)
throw(ErrorException("Could not find package $pkgname"))
If you want to be thorough you should take the possibility of multiple packages with the same name into account. Then you need to look up the UUID from your environment and use that as key to the registry instances. Potentially you could also find the same package in multiple registries, possibly with different repo URLs.
If you don’t have a need to cover those possibilities, your function is fine.