Skip to contents

Lists file and directory names found under the specified path in a GitLab repository via the GET /projects/:id/repository/tree endpoint of GitLab's v4 RESTful API.

Usage

dir_ls(
  path = "",
  id_project = funky::config_val("id_project"),
  recurse = FALSE,
  ref = project_default_branch(id_project = id_project, base_url = base_url, token =
    token, max_tries = max_tries),
  base_url = funky::config_val("base_url"),
  token = funky::config_val("token"),
  max_tries = 3L
)

Arguments

path

character(1)
Directory path, relative to the repository root.

id_project

integer(1)
GitLab project identifier.

recurse

logical(1)
Whether or not to recurse into subdirectories of path.

ref

character(1)
Git revision expression matching the desired Git tree object, e.g. a ref name (branch, tag, etc.), a commit identifier, or another symbolic reference like "HEAD~10". Omitted if NULL, otherwise set as a URL parameter in the API request. Note that the GitLab API doesn't support every type of revision expression.

base_url

character(1)
Base URL to the GitLab v4 RESTful API root.

token

character(1)
GitLab access token used for authentication. If NULL, the API request is made unauthenticated which results in HTTP 404 Not Found and other errors for non-public resources.

max_tries

integer(1)
Maximum number of request attempts in case of an HTTP error. An integerish scalar. Retries are performed using exponential backoff and jitter, see httr2::req_retry() for details.

Value

A tibble.

See also

Other functions to manage directories on GitLab: dir_delete(), dir_exists()

Examples

gitlab::dir_ls(id_project = 64767928,
               path = "Rmd")
#> # A tibble: 2 × 5
#>   id                                       name               type  path                   mode  
#>   <chr>                                    <chr>              <chr> <chr>                  <chr> 
#> 1 d2023d5174b3ffd478d129de173c5523552fa9c5 gitlab.Rmd         blob  Rmd/gitlab.Rmd         100644
#> 2 c67e54626904e5238a2e48200299ca1e28a471ec sysdata.nopurl.Rmd blob  Rmd/sysdata.nopurl.Rmd 100644

# look for the pkgdown sitemap(s)
gitlab::dir_ls(id_project = 64767928,
               path = "docs",
               recurse = TRUE) |>
  dplyr::filter(stringr::str_detect(name, "\\.xml$")) |>
  dplyr::pull("path")
#> [1] "docs/dev/sitemap.xml"