Skip to content

Commit a0835db

Browse files
committed
Make some git messages less wordy.
1 parent da18e11 commit a0835db

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

R/pr.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ pr_resume <- function(branch = NULL) {
258258
))
259259
}
260260

261-
challenge_uncommitted_changes()
261+
challenge_uncommitted_changes(which = "switch")
262262

263263
ui_bullets(c("v" = "Switching to branch {.val {branch}}."))
264264
gert::git_branch_checkout(branch, repo = repo)
@@ -283,7 +283,7 @@ pr_resume <- function(branch = NULL) {
283283
pr_fetch <- function(number = NULL, target = c("source", "primary")) {
284284
repo <- git_repo()
285285
tr <- target_repo(github_get = NA, role = target, ask = FALSE)
286-
challenge_uncommitted_changes()
286+
challenge_uncommitted_changes(which = "switch")
287287

288288
if (is.null(number)) {
289289
ui_bullets(c("i" = "No PR specified ... looking up open PRs."))
@@ -377,7 +377,7 @@ pr_push <- function() {
377377
check_for_config(cfg, ok_configs = c("ours", "fork"))
378378
default_branch <- git_default_branch()
379379
check_pr_branch(default_branch)
380-
challenge_uncommitted_changes()
380+
challenge_uncommitted_changes(which = "push")
381381

382382
branch <- git_branch()
383383
remref <- git_branch_tracking(branch)
@@ -425,7 +425,7 @@ pr_pull <- function() {
425425
check_for_config(cfg)
426426
default_branch <- git_default_branch()
427427
check_pr_branch(default_branch)
428-
challenge_uncommitted_changes()
428+
challenge_uncommitted_changes(which = "pull")
429429

430430
git_pull()
431431

@@ -440,7 +440,7 @@ pr_pull <- function() {
440440
#' @rdname pull-requests
441441
pr_merge_main <- function() {
442442
tr <- target_repo(github_get = TRUE, ask = FALSE)
443-
challenge_uncommitted_changes()
443+
challenge_uncommitted_changes(which = "pull")
444444
remref <- glue("{tr$remote}/{tr$default_branch}")
445445
ui_bullets(c("v" = "Pulling changes from {.val {remref}}."))
446446
git_pull(remref, verbose = FALSE)
@@ -503,7 +503,7 @@ pr_pause <- function() {
503503
))
504504
return(invisible())
505505
}
506-
challenge_uncommitted_changes()
506+
challenge_uncommitted_changes(which = "switch")
507507
# TODO: what happens here if offline?
508508
check_branch_pulled(use = "pr_pull()")
509509

R/utils-git.R

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,10 @@ git_uncommitted <- function(untracked = FALSE) {
181181
nrow(git_status(untracked)) > 0
182182
}
183183

184-
challenge_uncommitted_changes <- function(untracked = FALSE, msg = NULL) {
184+
challenge_uncommitted_changes <- function(
185+
untracked = FALSE,
186+
msg = NULL,
187+
which = c("push", "pull", "switch", "compare branches")) {
185188
if (!uses_git()) {
186189
return(invisible())
187190
}
@@ -192,7 +195,7 @@ challenge_uncommitted_changes <- function(untracked = FALSE, msg = NULL) {
192195

193196
default_msg <- "
194197
There are uncommitted changes, which may cause problems or be lost when \\
195-
we push, pull, switch, or compare branches"
198+
we {.or {which}}"
196199
msg <- glue(msg %||% default_msg)
197200
if (git_uncommitted(untracked = untracked)) {
198201
if (ui_yep(c(
@@ -201,7 +204,7 @@ challenge_uncommitted_changes <- function(untracked = FALSE, msg = NULL) {
201204
))) {
202205
return(invisible())
203206
} else {
204-
ui_abort("Uncommitted changes. Please commit before continuing.")
207+
ui_abort("Uncommitted changes. Please commit before continuing.", call = NULL)
205208
}
206209
}
207210
}

0 commit comments

Comments
 (0)