Skip to contents

Retrieves the list of branches for one or more repositories within a specified GitHub organisation or user account.

It accepts either: * a character vector of repository names, or * a data frame containing a `repo_name` column (for example, the output of [get_repos()])

The function returns a named list where each element contains the GitHub API response for the corresponding repository.

Usage

get_branches(repos, org, token = get_token())

Arguments

repos

A character vector of repository names, or a data frame with a column named `repo_name`. If a data frame is supplied without this column, an error is raised.

org

A single character string giving the GitHub organisation or username that owns the repositories.

token

A GitHub installation access token or personal access token. The default is `get_token()`, which should return a valid token for accessing repositories through the GitHub App.

Value

A named list with one element per repository. Each element contains the raw GitHub API response for the branches in that repository.

Details

Each repository is queried through the GitHub API endpoint: `GET /repos/{org}/{repo}/branches`

The data response includes metadata for each repository, such as its name, visibility, creation date, and issue counts. Use [tidy_repos] to convert this into a tidy data frame.

This function is often used after calling [get_repos()] and [tidy_repos()], which return a data frame containing a `repo_name` column.

See also

* [get_repos()] for retrieving repository names * [tidy_repos()] for converting the list format to a data frame * [get_token()] for obtaining the GitHub App installation token

Examples

if (FALSE) { # \dontrun{
# Using a character vector
get_branches(c("repo1", "repo2"), org = "my-org")

# Using a data frame returned by get_repos()
repos <- get_repos(org = "my-org") |>  tidy_repos()
get_branches(repos, org = "my-org")
} # }