Skip to content

Commit

Permalink
feat: bump_version(check_default_branch = TRUE)
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed Aug 18, 2024
1 parent 2e86485 commit 271429b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
19 changes: 14 additions & 5 deletions R/api-bump-version.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
#' Calls the following functions:
#'
#' @inheritParams update_version
#' @inheritParams rlang::args_dots_empty
#' @param no_change_behavior What to do if there was no change since the last
#' version: `"bump"` for bump the version;
#' `"noop"` for do nothing;
#' `"fail"` for erroring.
#' version: `"bump"` for bump the version;
#' `"noop"` for do nothing;
#' `"fail"` for erroring.
#' @param check_default_branch Whether to check that the current branch is the
#' default branch.
#' @return
#' `TRUE` if `NEWS.md` and `DESCRIPTION` have been updated,
#' `FALSE` otherwise.
Expand All @@ -25,7 +28,12 @@
#' @example man/examples/bump-version.R
bump_version <- function(
which = c("dev", "patch", "pre-minor", "minor", "pre-major", "major"),
no_change_behavior = c("bump", "noop", "fail")) {
...,
no_change_behavior = c("bump", "noop", "fail"),
check_default_branch = TRUE
) {
check_dots_empty()

which <- arg_match(which)
no_change_behavior <- arg_match(no_change_behavior)

Expand All @@ -43,7 +51,8 @@ bump_version <- function(
new_fledgeling <- bump_version_impl(
fledgeling,
which = which,
no_change_behavior = no_change_behavior
no_change_behavior = no_change_behavior,
check_default_branch = check_default_branch
)

invisible(!identical(new_fledgeling, fledgeling))
Expand Down
8 changes: 6 additions & 2 deletions R/bump-version.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
bump_version_impl <- function(fledgeling,
which,
no_change_behavior,
check_default_branch = TRUE,
edit = TRUE,
no_change_message = NULL) {
#' @description
#' 1. Verify that the current branch is the main branch.
check_main_branch("bump_version()")
#' 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()")
}
#' 1. Check if there were changes since the last version.
if (no_change()) {
if (no_change_behavior == "fail") {
Expand Down
12 changes: 10 additions & 2 deletions man/bump_version.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 271429b

Please sign in to comment.