@@ -196,8 +196,11 @@ pr_init <- function(branch) {
196
196
}
197
197
}
198
198
199
- default_branch <- if (online ) git_default_branch_(cfg ) else
199
+ default_branch <- if (online ) {
200
+ git_default_branch_(cfg )
201
+ } else {
200
202
guess_local_default_branch()
203
+ }
201
204
challenge_non_default_branch(
202
205
" Are you sure you want to create a PR branch based on a non-default branch?" ,
203
206
default_branch = default_branch
@@ -627,11 +630,25 @@ pr_clean <- function(
627
630
))
628
631
tryCatch(
629
632
gert :: git_branch_delete(pr_local_branch , repo = repo ),
630
- error = function (e ) {
631
- saveRDS(e , " ~/rrr/usethis/oops.rds" )
632
- ui_bullets(c(
633
- " !" = " Wrote an error from git_branch_delete() to oops.rds!"
634
- ))
633
+ libgit2_error = function (e ) {
634
+ if (identical(Sys.getenv(" USER" ), " jenny" )) {
635
+ write_to <- glue(" ~/rrr/usethis/pr-finish-oops-{project_name()}.rds" )
636
+ saveRDS(e , write_to )
637
+ ui_bullets(c(
638
+ " !" = " Wrote an error from {.fun git_branch_delete} to {.path {pth(write_to, base = NA)}}!"
639
+ ))
640
+ }
641
+ # The expected error doesn't have a distinctive class, so we have to
642
+ # detect it based on the message.
643
+ # If we got an unexpected libgit2 error, rethrow.
644
+ if (
645
+ ! grepl(
646
+ " could not find key 'branch[.].+[.]vscode-merge-base' to delete" ,
647
+ e $ message
648
+ )
649
+ ) {
650
+ stop(e )
651
+ }
635
652
}
636
653
)
637
654
}
0 commit comments