@@ -184,7 +184,7 @@ pr_init <- function(branch) {
184184 }
185185 }
186186
187- default_branch <- git_default_branch( )
187+ default_branch <- git_default_branch_( cfg )
188188 challenge_non_default_branch(
189189 " Are you sure you want to create a PR branch based on a non-default branch?" ,
190190 default_branch = default_branch
@@ -237,7 +237,7 @@ pr_resume <- function(branch = NULL) {
237237 ui_bullets(c(
238238 " i" = " No branch specified ... looking up local branches and associated PRs."
239239 ))
240- default_branch <- git_default_branch ()
240+ default_branch <- guess_local_default_branch ()
241241 branch <- choose_branch(exclude = default_branch )
242242 if (is.null(branch )) {
243243 ui_bullets(c(" x" = " Repo doesn't seem to have any non-default branches." ))
@@ -375,7 +375,7 @@ pr_push <- function() {
375375 repo <- git_repo()
376376 cfg <- github_remote_config(github_get = TRUE )
377377 check_for_config(cfg , ok_configs = c(" ours" , " fork" ))
378- default_branch <- git_default_branch( )
378+ default_branch <- git_default_branch_( cfg )
379379 check_pr_branch(default_branch )
380380 challenge_uncommitted_changes()
381381
@@ -423,7 +423,7 @@ pr_push <- function() {
423423pr_pull <- function () {
424424 cfg <- github_remote_config(github_get = TRUE )
425425 check_for_config(cfg )
426- default_branch <- git_default_branch( )
426+ default_branch <- git_default_branch_( cfg )
427427 check_pr_branch(default_branch )
428428 challenge_uncommitted_changes()
429429
@@ -449,11 +449,12 @@ pr_merge_main <- function() {
449449# ' @export
450450# ' @rdname pull-requests
451451pr_view <- function (number = NULL , target = c(" source" , " primary" )) {
452- tr <- target_repo(github_get = NA , role = target , ask = FALSE )
452+ cfg <- github_remote_config(github_get = NA )
453+ tr <- target_repo(cfg , github_get = NA , role = target , ask = FALSE )
453454 url <- NULL
454455 if (is.null(number )) {
455456 branch <- git_branch()
456- default_branch <- git_default_branch( )
457+ default_branch <- git_default_branch_( cfg )
457458 if (branch != default_branch ) {
458459 url <- pr_url(branch = branch , tr = tr )
459460 if (is.null(url )) {
@@ -491,11 +492,11 @@ pr_view <- function(number = NULL, target = c("source", "primary")) {
491492# ' @export
492493# ' @rdname pull-requests
493494pr_pause <- function () {
494- # intentionally naive selection of target repo
495- tr <- target_repo(github_get = FALSE , ask = FALSE )
495+ cfg <- github_remote_config( github_get = NA )
496+ tr <- target_repo(cfg , github_get = NA , ask = FALSE )
496497
497498 ui_bullets(c(" v" = " Switching back to the default branch." ))
498- default_branch <- git_default_branch( )
499+ default_branch <- git_default_branch_( cfg )
499500 if (git_branch() == default_branch ) {
500501 ui_bullets(c(
501502 " !" = " Already on this repo's default branch ({.val {default_branch}}),
@@ -535,8 +536,10 @@ pr_clean <- function(number = NULL,
535536 withr :: defer(rstudio_git_tickle())
536537 mode <- match.arg(mode )
537538 repo <- git_repo()
538- tr <- target_repo(github_get = NA , role = target , ask = FALSE )
539- default_branch <- git_default_branch()
539+
540+ cfg <- github_remote_config(github_get = NA )
541+ tr <- target_repo(cfg , github_get = NA , role = target , ask = FALSE )
542+ default_branch <- git_default_branch_(cfg )
540543
541544 if (is.null(number )) {
542545 check_pr_branch(default_branch )
@@ -629,14 +632,10 @@ pr_clean <- function(number = NULL,
629632# we're in DEFAULT branch of a fork. I wish everyone set up DEFAULT to track the
630633# DEFAULT branch in the source repo, but this protects us against sub-optimal
631634# setup.
632- pr_pull_source_override <- function (tr = NULL , default_branch = NULL ) {
633- # naive selection of target repo; calling function should analyse the config
634- tr <- tr %|| % target_repo(github_get = FALSE , ask = FALSE )
635-
635+ pr_pull_source_override <- function (tr , default_branch ) {
636636 # TODO: why does this not use a check_*() function, i.e. shared helper?
637637 # I guess to issue a specific error message?
638638 current_branch <- git_branch()
639- default_branch <- default_branch %|| % git_default_branch()
640639 if (current_branch != default_branch ) {
641640 ui_abort("
642641 Internal error: {.fun pr_pull_source_override} should only be used when on
@@ -994,7 +993,7 @@ pr_branch_delete <- function(pr) {
994993 invisible (TRUE )
995994}
996995
997- check_pr_branch <- function (default_branch = git_default_branch() ) {
996+ check_pr_branch <- function (default_branch ) {
998997 # the glue-ing happens inside check_current_branch(), where `gb` gives the
999998 # current git branch
1000999 check_current_branch(
0 commit comments