gh_dir_ls | R Documentation |
Lists file and directory names found under
rev:path
in a GitHub repository via
GitHub's GraphQL API.
gh_dir_ls(
owner,
name,
path = ".",
rev = "HEAD",
recurse = TRUE,
incl_dirs = TRUE,
incl_files = TRUE
)
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 recurse into subdirectories of |
incl_dirs |
Whether or not to list directories (and subdirectories if |
incl_files |
Whether or not to list files (also inside subdirectories if |
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 an empty character vector is returned in case path
is invalid or no file/directory exists underneath path
.
A character vector of paths to the files and subdirectories found under rev:path
, relative to the repository root.
Other GitHub functions:
gh_release_latest()
,
gh_releases()
,
gh_text_file()
,
gh_text_files()
# you can opt-out from directory recursion
yay::gh_dir_ls(owner = "rpkg-dev",
name = "pal",
recurse = FALSE) |>
pal::cat_lines()
# you can list only files in a directory
yay::gh_dir_ls(owner = "rpkg-dev",
name = "pal",
path = "tests",
incl_dirs = FALSE) |>
pal::cat_lines()
# or you can list only directories in a directory
yay::gh_dir_ls(owner = "rpkg-dev",
name = "pal",
path = "tests",
incl_files = FALSE) |>
pal::cat_lines()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.