gh_text_files | R Documentation |
Downloads all text files under the specified path from a GitHub repository via GitHub's GraphQL API and returns a named character vector with the file paths as names and the file contents as values.
This is a simple convenience function combining gh_dir_ls()
and gh_text_file()
.
gh_text_files(owner, name, path = ".", rev = "HEAD", recurse = FALSE)
owner |
Repository owner's GitHub user or organization name. A character scalar. |
name |
Repository name. A character scalar. |
path |
Path to a directory, relative to the repository root. A character scalar. |
rev |
Git revision expression matching the desired Git tree object, e.g. a branch or tag
name or another symbolic reference like |
recurse |
Whether or not to also include text files in subfolders of |
Works for both public and private repositories, for the latter you just need to set up a sufficiently authorized GitHub Personal Access Token (PAT).
Note that nothing is returned in case of a binary file, as if no file at all existed under the given
path
.
A named character vector of length equal to the number of files found under rev:path
with the file paths as names and the file contents as values.
Other GitHub functions:
gh_dir_ls()
,
gh_release_latest()
,
gh_releases()
,
gh_text_file()
yay::gh_text_files(owner = "rpkg-dev",
name = "pal",
path = "tests") |>
str()
# you have to opt-in into directory recursion
yay::gh_text_files(owner = "rpkg-dev",
name = "pal",
path = "tests",
recurse = TRUE) |>
str()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.