R/github_files.R

Defines functions github_files

Documented in github_files

#' List files in GitHub repository
#'
#' @param repo a \code{string} specifying the github username/repository
#'
#' @keywords internal
#'
github_files <- function(repo) {
  req <- httr::GET(paste("https://api.github.com/repos", repo,
                         "git/trees/main?recursive=1", sep = "/"))
  if (req$status_code == 404) {
    req <- httr::GET(paste("https://api.github.com/repos", repo,
                           "git/trees/master?recursive=1", sep = "/"))
  }
  httr::stop_for_status(req)
  unlist(lapply(httr::content(req)$tree, "[", "path"), use.names = F)
}

Try the rDataPipeline package in your browser

Any scripts or data that you put into this service are public.

rDataPipeline documentation built on Nov. 18, 2021, 1:14 a.m.