Skip to contents

This function creates pull requests across multiple GitHub repositories, applying the same set of file changes to each repository. It can create new branches as needed, add or update files, and then open pull requests.

Usage

pr_create(
  repos,
  branch_name,
  base_branch = NULL,
  title,
  body,
  create_branch = TRUE,
  file_mapping,
  dry_run = FALSE,
  quiet = FALSE
)

Arguments

repos

Data frame of repositories as returned by repos(), with at least columns for full_name and default_branch

branch_name

Character string with the name of the branch to create for the changes

base_branch

Character string with the name of the base branch. Default is NULL (uses default branch).

title

Character string with the PR title

body

Character string with the PR description

create_branch

Logical indicating whether to create the branch if it doesn't exist. Default is TRUE.

file_mapping

List mapping local file paths to repository paths, as created by file_mapping()

dry_run

Logical indicating whether to only simulate the changes. Default is FALSE.

quiet

Logical; if TRUE, suppresses progress and status messages. Default is FALSE.

Value

Returns a data.frame with class "pr_create_result" containing the following columns:

repository

Character, the full repository name (owner/repo)

pr_url

Character, the URL of the created pull request, or NA if no PR was created

status

Character, indicating the operation result: "created", "would_create", "skipped", or "error"

message

Character, a description of the action taken or error encountered

See also

print.pr_create_result() to display the results in a formatted way.

Examples

if (FALSE) { # interactive()
# Get repositories and create file mapping
repositories <- repos("my-organization")
mapping <- file_mapping(
  "local/path/file1.R" = ".github/workflows/ci.yml",
  "local/path/file2.R" = "R/utils.R"
)

# Create pull requests in all repositories
results <- pr_create(
  repos = repositories, 
  branch_name = "feature-branch", 
  title = "Update CI workflow", 
  body = "Standardizing CI workflow across repositories", 
  file_mapping = mapping
)

# Simulate without making actual changes
dry_run_results <- pr_create(
  repos = repositories, 
  branch_name = "feature-branch", 
  title = "Update documentation", 
  body = "Updating documentation with new examples", 
  file_mapping = mapping,
  dry_run = TRUE
)

# Only create PRs in repositories where the branch already exists
existing_branch_results <- pr_create(
  repos = repositories, 
  branch_name = "existing-branch", 
  title = "Fix existing branch", 
  body = "Apply fixes to existing branch", 
  file_mapping = mapping,
  create_branch = FALSE
)
}