according this post: Using CURL to list github repository tree (github API) the way to get the complete file listing recursively is to start by passing the tree sha to the endpoint.
The answer provided suggests that you can use the sha from a commit, but that only seems to get information for that commit, and the question that was asked, "how do you get the sha for a tree" remains unanswered.
I'd like to know this, and I don't want to get into dozens or hundreds of queries. I'm dealing with small repos that may have a half dozen directory levels, and maybe 200 files, all svgs.
What's the trick here? The documentation isn't that helpful, almost as though this were a task not many people need to do, which seems really unlikely.
The tree sha is just a commitish hash. This means your can use any SHA hash referring a tag, a commit, a release or even raw branch name:
const response = await octokit.request(
`GET /repos/{owner}/{repo}/git/trees/{tree_sha}?recursive=1`,
{
owner: <login>,
repo: <repo>,
tree_sha: "master",
}
);
and the question that was asked, "how do you get the sha for a tree" remains unanswered.
To answer that, you first need to know what you are trying to get, since commitish hashes can be anything there's a plenty of ways:
See also https://stackoverflow.com/a/23303550/11793117.
"Commit-ish" are identifiers that ultimately lead to a commit object. For example, tag -> commit. "Tree-ish" are identifiers that ultimately lead to tree (i.e. directory) objects.