Skip to content

Commit 3b6847f

Browse files
olivroyjennybc
andauthored
Add option to merge conflicts without opening the files (#1949)
* Add option to merge conflicts without opening the files * Refactor * Tweak the question --------- Co-authored-by: Jennifer (Jenny) Bryan <[email protected]>
1 parent a919437 commit 3b6847f

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# usethis (development version)
22

3+
* `pr_merge_main()` now offers the choice to not open the files with merge conflicts (@olivroy, #1720).
4+
35
* `edit_rstudio_snippets()` now accepts yaml snippets (@olivroy, #1941).
46

57
* `use_standalone()` inserts an improved header that includes the code needed to

R/utils-git.R

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -224,23 +224,28 @@ git_conflict_report <- function() {
224224
bulletize(conflicted_paths, n_show = 10)
225225
))
226226

227-
msg <- c(
228-
"!" = "Are you ready to sort this out?",
229-
" " = "If so, we will open the conflicted files for you to edit."
230-
)
231-
yes <- "Yes, I'm ready to resolve the merge conflicts."
227+
yes <- "Yes, open the conflicted files for editing."
228+
yes_soft <- "Yes, but do not open the conflicted files."
232229
no <- "No, I want to abort this merge."
233-
if (ui_yep(msg, yes = yes, no = no, shuffle = FALSE)) {
234-
ui_silence(purrr::walk(conflicted, edit_file))
235-
ui_abort(c(
236-
"Please fix each conflict, save, stage, and commit.",
237-
"To back out of this merge, run {.code gert::git_merge_abort()}
238-
(in R) or {.code git merge --abort} (in the shell)."
239-
))
240-
} else {
230+
choice <- utils::menu(
231+
title = "Do you want to proceed with this merge?",
232+
choices = c(yes, yes_soft, no),
233+
title = msg
234+
)
235+
236+
if (choice < 1 || choice > 2) {
241237
gert::git_merge_abort(repo = git_repo())
242238
ui_abort("Abandoning the merge, since it will cause merge conflicts.")
243239
}
240+
241+
if (choice == 1) {
242+
ui_silence(purrr::walk(conflicted, edit_file))
243+
}
244+
ui_abort(c(
245+
"Please fix each conflict, save, stage, and commit.",
246+
"To back out of this merge, run {.code gert::git_merge_abort()}
247+
(in R) or {.code git merge --abort} (in the shell)."
248+
))
244249
}
245250

246251
# Remotes ----------------------------------------------------------------------

0 commit comments

Comments
 (0)