Method: projects.locations.repositories.fetchTree

Fetches a tree from a repository.

HTTP request


The URLs use gRPC Transcoding syntax.

Path parameters

Parameters
repository

string

Required. The format is projects/{project_number}/locations/{locationId}/repositories/{repositoryId}. Specifies the repository to fetch the tree from.

Query parameters

Parameters
ref

string

Optional. ref can be a SHA-1 hash, a branch name, or a tag. Specifies which tree to fetch. If not specified, the default branch will be used.

recursive

boolean

Optional. If true, include all subfolders and their files in the response. If false, only the immediate children are returned.

pageSize

integer

Optional. Requested page size. Server may return fewer items than requested. If unspecified, at most 10,000 items will be returned.

pageToken

string

Optional. A token identifying a page of results the server should return.

Request body

The request body must be empty.

Response body

Response message containing a list of TreeEntry objects.

If successful, the response body contains data with the following structure:

JSON representation
{
  "treeEntries": [
    {
      object (TreeEntry)
    }
  ],
  "nextPageToken": string
}
Fields
treeEntries[]

object (TreeEntry)

The list of TreeEntry objects.

nextPageToken

string

A token identifying a page of results the server should return.

Authorization scopes

Requires the following OAuth scope:

  • https://www.googleapis.com/auth/cloud-platform

For more information, see the Authentication Overview.

IAM Permissions

Requires the following IAM permission on the repository resource:

  • securesourcemanager.repositories.fetch

For more information, see the IAM documentation.

TreeEntry

Represents an entry within a tree structure (like a Git tree).

JSON representation
{
  "type": enum (ObjectType),
  "sha": string,
  "path": string,
  "mode": string,
  "size": string
}
Fields
type

enum (ObjectType)

Output only. The type of the object (TREE, BLOB, COMMIT). Output-only.

sha

string

Output only. The SHA-1 hash of the object (unique identifier). Output-only.

path

string

Output only. The path of the file or directory within the tree (e.g., "src/main/java/MyClass.java"). Output-only.

mode

string

Output only. The file mode as a string (e.g., "100644"). Indicates file type. Output-only.

size

string (int64 format)

Output only. The size of the object in bytes (only for blobs). Output-only.

ObjectType

Defines the type of object the TreeEntry represents.

Enums
OBJECT_TYPE_UNSPECIFIED Default value, indicating the object type is unspecified.
TREE Represents a directory (folder).
BLOB Represents a file (contains file data).
COMMIT Represents a pointer to another repository (submodule).