getTree method

Future<GitTree> getTree(
  1. RepositorySlug slug,
  2. String? sha, {
  3. bool recursive = false,
})

Fetches a tree from a repository for the given ref sha.

If recursive is set to true, the tree is fetched recursively.

API docs: https://developer.github.com/v3/git/trees/#get-a-tree and https://developer.github.com/v3/git/trees/#get-a-tree-recursively

Implementation

Future<GitTree> getTree(RepositorySlug slug, String? sha,
    {bool recursive = false}) {
  var path = '/repos/${slug.fullName}/git/trees/$sha';
  if (recursive) {
    path += '?recursive=1';
  }

  return github.getJSON(path,
      convert: (dynamic j) => GitTree.fromJson(j),
      statusCode: StatusCodes.OK);
}