Skip to content

Commit f7854a8

Browse files
committed
Fixup so I can invite others to try this out
1 parent 0d3cb3d commit f7854a8

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

R/pr.R

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,11 @@ pr_init <- function(branch) {
196196
}
197197
}
198198

199-
default_branch <- if (online) git_default_branch_(cfg) else
199+
default_branch <- if (online) {
200+
git_default_branch_(cfg)
201+
} else {
200202
guess_local_default_branch()
203+
}
201204
challenge_non_default_branch(
202205
"Are you sure you want to create a PR branch based on a non-default branch?",
203206
default_branch = default_branch
@@ -627,11 +630,25 @@ pr_clean <- function(
627630
))
628631
tryCatch(
629632
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+
}
635652
}
636653
)
637654
}

0 commit comments

Comments
 (0)