-
Notifications
You must be signed in to change notification settings - Fork 155
Description
remotes::install_github()
assumes that the default branch is named "master", which is not always the case, e.g.
remotes::install_github("elizagrames/litsearchr")
#> Using github PAT from envvar GITHUB_PAT
#> Downloading GitHub repo elizagrames/litsearchr@master
#> Error in utils::download.file(url, path, method = method, quiet = quiet, :
#> cannot open URL 'https://api.github.com/repos/elizagrames/litsearchr/tarball/master'
Created on 2020-06-13 by the reprex package (v0.3.0)
The GitHub API notes a default_branch
field that could provide this information, e.g.:
remotes:::github_GET("repos/elizagrames/litsearchr")$default_branch
#> [1] "main"
Created on 2020-06-13 by the reprex package (v0.3.0)
So, I think this can be a drop-in for the default value for the ref
argument in install_github
. Some additional re-factoring might be needed if we wanted to bundle the GitHub API calls.
Note, to my knowledge, this issue was first reported by @elizagrames on twitter, and we chatted about a potential fix before writing up this issue. We're happy to work on a PR to this, and look into propagating the solution to other install_*
functions, if so desired.