Skip to contents

Fetches a GitLab project's file tree (following pagination, since GitLab's tree endpoint caps at 100 entries per page, unlike GitHub's single-request Git Trees API), its detected licence, and default branch. File sizes are backfilled with a single batched GraphQL repository.blobs(paths: [...]) query, since the REST tree listing does not include size.

Usage

gitlab_tree_files(repo)

Arguments

repo

GitLab project URL or "namespace/project" string

Value

a list with:

gated

logical; TRUE only when the project could not be listed at all (invalid/inaccessible)

reason

character reason, or NA

files

data.frame with repo/clean_repo/name/path/ download_url/size/type, or NULL when the tree could not be fetched

default_branch

character

license

character SPDX-style key (e.g. "mit"), or NA

Examples

# \donttest{
if (online("gitlab.com")) {
  tree <- gitlab_tree_files("gitlab.com/gitlab-org/gitlab-test")
  head(tree$files$name)
}
#> [1] ".gitattributes"  ".gitignore"      ".gitmodules"     "CHANGELOG"      
#> [5] "CONTRIBUTING.md" "Gemfile.zip"    
# }