Skip to content

Commit

Permalink
Ensure that remote_sha.github honours credentials (fixes r-lib#1827)
Browse files Browse the repository at this point in the history
  • Loading branch information
renozao committed Jul 23, 2018
1 parent 56ee182 commit b958ee3
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions R/install-github.r
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,19 @@ remote_package_name.github_remote <- function(remote, url = "https://raw.githubu

#' @export
remote_sha.github_remote <- function(remote, url = "https://github.com", ...) {

# honour credentials if any
cred <- if( !is.null(remote$auth_token) ){
usr <- remote$auth_user
if( is.null(usr) ) usr <- "__anonymous__" # NOTE: an empty string seems to cause git2r::remote_ls to hang
git2r::cred_user_pass(usr, remote$auth_token)

}

tryCatch({
res <- git2r::remote_ls(
paste0(url, "/", remote$username, "/", remote$repo, ".git"),
credentials = cred,
...)

found <- grep(pattern = paste0("\\b", remote$ref), x = names(res), perl = TRUE)
Expand Down

0 comments on commit b958ee3

Please sign in to comment.