Skip to contents

Fetches the complete file tree of a GitHub repository in two API calls (repo metadata + recursive tree), rather than the N-request recursive /contents/ crawl used by github_files().

Usage

github_tree_files(repo)

Arguments

repo

GitHub repo URL or "owner/repo" string

Value

a list with:

gated

logical; TRUE only when the repository could not be listed at all (invalid/inaccessible, or a truncated tree)

reason

character reason, or NA

files

data.frame shaped like github_files() output, or NULL when the tree could not be fetched

default_branch

character

license

character licence key, or NA

Details

A repository is listed in full whatever its size, matching how every other archive source (OSF, Zenodo, ResearchBox, PsychArchives, local) is treated. Because the Git Trees API returns the whole tree in ONE request, listing a large repository costs no more than listing a small one, so there is nothing to protect against at this stage. What a repository's size does limit is how much of it is DOWNLOADED, and that is handled downstream by download_repo_files()'s per-file and per-repository budgets, which fill smallest-file-first up to the cap and report what was omitted.

The one case that still refuses is GitHub's own hard API limit: a tree with more than 100,000 entries comes back flagged truncated, meaning the response is incomplete. There is no way to list such a repository through this endpoint, so it is reported rather than silently returning a partial file list.

Examples

# \donttest{
if (online("api.github.com")) {
  tree <- github_tree_files("scienceverse/metacheck")
  head(tree$files$name)
}
#> [1] ".Rbuildignore"  ".gitattributes" ".gitignore"     "CODEOWNERS"    
#> [5] "bug_report.md"  "config.yml"    
# }