Skip to content

Instantly share code, notes, and snippets.

@jakubsob
Created December 18, 2024 12:17
Show Gist options
  • Save jakubsob/16d9fe7560a74189099bd7553f41d916 to your computer and use it in GitHub Desktop.
Save jakubsob/16d9fe7560a74189099bd7553f41d916 to your computer and use it in GitHub Desktop.
Open a PR using a selected template
.get_active_branch <- function() {
res <- system("git status", intern = TRUE)
stringr::str_remove(res[1], "On branch ")
}
#' It opens a PR in the repository with the selected template
#'
#' The only way to open a PR with a specific template is to use the query parameters:
#' https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/using-query-parameters-to-create-a-pull-request
.open_pr <- function(
repository,
from = .get_active_branch(),
to = "dev",
template = "dev.md") {
browseURL(glue::glue("{repository}/compare/{to}...{from}?expand=1&template={template}"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment