Skip to content

Commit

Permalink
feat: Mention bump_version(check_default_branch = FALSE) in error m…
Browse files Browse the repository at this point in the history
…essage (#812)
  • Loading branch information
krlmlr authored Nov 21, 2024
1 parent 3b372f6 commit 0c102ad
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion R/bump-version.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ bump_version_impl <- function(fledgeling,
#' 1. Verify that the current branch is the main branch
#' if `check_default_branch = TRUE` (the default).
if (check_default_branch) {
check_main_branch("bump_version()")
check_main_branch("bump_version()", "bump_version(check_default_branch = FALSE)")
}
#' 1. [update_news()], using the `which` argument.
out <- update_news_impl(
Expand Down
5 changes: 3 additions & 2 deletions R/utils-git.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
check_main_branch <- function(reason) {
check_main_branch <- function(reason, alternative = NULL) {
if (get_branch_name() != get_main_branch()) {
cli::cli_abort(
c(
x = "Must be on the main branch ({.val {get_main_branch()}}) for running {.code {reason}}.",
i = "Currently on branch {.val {get_branch_name()}}."
i = "Currently on branch {.val {get_branch_name()}}.",
i = if (!is.null(alternative)) "Consider running {.run {alternative}}."
)
)
}
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/_snaps/bump_version.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
Error in `check_main_branch()`:
x Must be on the main branch ("main") for running `bump_version()`.
i Currently on branch "bla".
i Consider running `bump_version(check_default_branch = FALSE)`.

# bump_version() errors well for wrong arguments

Expand Down

0 comments on commit 0c102ad

Please sign in to comment.