@@ -184,7 +184,7 @@ pr_init <- function(branch) {
184
184
}
185
185
}
186
186
187
- default_branch <- git_default_branch( )
187
+ default_branch <- git_default_branch_( cfg )
188
188
challenge_non_default_branch(
189
189
" Are you sure you want to create a PR branch based on a non-default branch?" ,
190
190
default_branch = default_branch
@@ -237,7 +237,7 @@ pr_resume <- function(branch = NULL) {
237
237
ui_bullets(c(
238
238
" i" = " No branch specified ... looking up local branches and associated PRs."
239
239
))
240
- default_branch <- git_default_branch ()
240
+ default_branch <- guess_local_default_branch ()
241
241
branch <- choose_branch(exclude = default_branch )
242
242
if (is.null(branch )) {
243
243
ui_bullets(c(" x" = " Repo doesn't seem to have any non-default branches." ))
@@ -375,7 +375,7 @@ pr_push <- function() {
375
375
repo <- git_repo()
376
376
cfg <- github_remote_config(github_get = TRUE )
377
377
check_for_config(cfg , ok_configs = c(" ours" , " fork" ))
378
- default_branch <- git_default_branch( )
378
+ default_branch <- git_default_branch_( cfg )
379
379
check_pr_branch(default_branch )
380
380
challenge_uncommitted_changes()
381
381
@@ -423,7 +423,7 @@ pr_push <- function() {
423
423
pr_pull <- function () {
424
424
cfg <- github_remote_config(github_get = TRUE )
425
425
check_for_config(cfg )
426
- default_branch <- git_default_branch( )
426
+ default_branch <- git_default_branch_( cfg )
427
427
check_pr_branch(default_branch )
428
428
challenge_uncommitted_changes()
429
429
@@ -449,11 +449,12 @@ pr_merge_main <- function() {
449
449
# ' @export
450
450
# ' @rdname pull-requests
451
451
pr_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 )
453
454
url <- NULL
454
455
if (is.null(number )) {
455
456
branch <- git_branch()
456
- default_branch <- git_default_branch( )
457
+ default_branch <- git_default_branch_( cfg )
457
458
if (branch != default_branch ) {
458
459
url <- pr_url(branch = branch , tr = tr )
459
460
if (is.null(url )) {
@@ -491,11 +492,11 @@ pr_view <- function(number = NULL, target = c("source", "primary")) {
491
492
# ' @export
492
493
# ' @rdname pull-requests
493
494
pr_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 )
496
497
497
498
ui_bullets(c(" v" = " Switching back to the default branch." ))
498
- default_branch <- git_default_branch( )
499
+ default_branch <- git_default_branch_( cfg )
499
500
if (git_branch() == default_branch ) {
500
501
ui_bullets(c(
501
502
" !" = " Already on this repo's default branch ({.val {default_branch}}),
@@ -535,8 +536,10 @@ pr_clean <- function(number = NULL,
535
536
withr :: defer(rstudio_git_tickle())
536
537
mode <- match.arg(mode )
537
538
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 )
540
543
541
544
if (is.null(number )) {
542
545
check_pr_branch(default_branch )
@@ -629,14 +632,10 @@ pr_clean <- function(number = NULL,
629
632
# we're in DEFAULT branch of a fork. I wish everyone set up DEFAULT to track the
630
633
# DEFAULT branch in the source repo, but this protects us against sub-optimal
631
634
# 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 ) {
636
636
# TODO: why does this not use a check_*() function, i.e. shared helper?
637
637
# I guess to issue a specific error message?
638
638
current_branch <- git_branch()
639
- default_branch <- default_branch %|| % git_default_branch()
640
639
if (current_branch != default_branch ) {
641
640
ui_abort("
642
641
Internal error: {.fun pr_pull_source_override} should only be used when on
@@ -994,7 +993,7 @@ pr_branch_delete <- function(pr) {
994
993
invisible (TRUE )
995
994
}
996
995
997
- check_pr_branch <- function (default_branch = git_default_branch() ) {
996
+ check_pr_branch <- function (default_branch ) {
998
997
# the glue-ing happens inside check_current_branch(), where `gb` gives the
999
998
# current git branch
1000
999
check_current_branch(
0 commit comments