diff --git a/R/auto.R b/R/auto.R index c83d1081..6466f4c0 100644 --- a/R/auto.R +++ b/R/auto.R @@ -51,25 +51,32 @@ plan_release <- function( } local_options(usethis.quiet = TRUE) - with_repo(plan_release_impl(which, force)) + local_repo() + + plan_release_impl(which, force) } plan_release_impl <- function(which, force) { # Checking if it's an orphan branch: https://github.com/r-lib/gert/issues/139 stopifnot(get_branch_name() != "HEAD") - # Do we need bump_version() first? - if (!no_change()) { - cli_abort(c( - "Aborting release process because not all changes were recorded.", - i = "Run {.run fledge::bump_version()}, then rerun {.run fledge::plan_release()}" - )) - } - # Check PAT early check_gh_pat("repo") - fledgeling <- read_fledgling() + orig_fledgeling <- read_fledgling() + + fledgeling <- update_news_impl( + default_commit_range(), + which = "dev", + fledgeling = orig_fledgeling, + no_change_message = NA_character_ + ) + + if (!identical(fledgeling, orig_fledgeling)) { + write_fledgling(fledgeling) + finalize_version_impl(push = TRUE) + } + new_version <- fledge_guess_version(fledgeling[["version"]], which) if (!force) { diff --git a/tests/testthat/_snaps/auto-full-cycle.md b/tests/testthat/_snaps/auto-full-cycle.md index 1f8a441c..a75b8c95 100644 --- a/tests/testthat/_snaps/auto-full-cycle.md +++ b/tests/testthat/_snaps/auto-full-cycle.md @@ -3,7 +3,24 @@ Code plan_release("next") Message - > Digesting messages from 1 commits. + > Digesting messages from 3 commits. + v Found 1 NEWS-worthy entry. + + -- Updating NEWS -- + + > Adding new entries to 'NEWS.md'. + + -- Updating Version -- + + v Package version bumped to 0.0.0.9001. + > Added header to 'NEWS.md'. + > Committing changes. + + -- Tagging Version -- + + > Creating tag v0.0.0.9001 with tag message derived from 'NEWS.md'. + > Pushing main. + > Force-pushing tag v0.0.0.9001. Output +------------------+ | | diff --git a/tests/testthat/_snaps/auto-pre.md b/tests/testthat/_snaps/auto-pre.md index abbcf145..a9d47027 100644 --- a/tests/testthat/_snaps/auto-pre.md +++ b/tests/testthat/_snaps/auto-pre.md @@ -12,7 +12,7 @@ Code plan_release("next") Message - > Digesting messages from 1 commits. + > Digesting messages from 2 commits. Output +------------------+ | | diff --git a/tests/testthat/_snaps/auto.md b/tests/testthat/_snaps/auto.md index 0f86b4e0..78a81927 100644 --- a/tests/testthat/_snaps/auto.md +++ b/tests/testthat/_snaps/auto.md @@ -17,36 +17,6 @@ Error in `gert::git_branch_create()`: ! Failed to find git reference 'blop' -# plan_release() works - - Code - plan_release("next") - Message - > Digesting messages from 1 commits. - Output - +------------------+ - | | - | plan_release | - | | - +------------------+ - Message - - -- 1. Creating a release branch and getting ready ------------------------------ - > Creating branch cran-0.0.1. - > Switching to branch cran-0.0.1. - > Committing changes. - - -- 2. Opening Pull Request for release branch ---------------------------------- - > Pushing cran-0.0.1 to remote origin. - > Opening draft pull request with contents from 'cran-comments.md'. - - -- 3. User Action Items -------------------------------------------------------- - * Run `devtools::check_win_devel()`. - * Run `urlchecker::url_update()`. - * Check all items in 'cran-comments.md'. - * Review 'NEWS.md'. - * Run `fledge::release()`. - # plan_release() -- force Code diff --git a/tests/testthat/test-auto-full-cycle.R b/tests/testthat/test-auto-full-cycle.R index d3d3600b..2758d47f 100644 --- a/tests/testthat/test-auto-full-cycle.R +++ b/tests/testthat/test-auto-full-cycle.R @@ -21,8 +21,8 @@ test_that("full cycle", { gert::git_commit("* Add cool bla.") local_fledge_quiet() - bump_version() - finalize_version(push = TRUE) + + # Deliberately without bump_version() ## init release ---- withr::local_envvar("FLEDGE_TEST_NOGH" = "no-github-no-mocking-needed-yay") diff --git a/tests/testthat/test-auto-pre.R b/tests/testthat/test-auto-pre.R index 102d0bd3..eb4a52c3 100644 --- a/tests/testthat/test-auto-pre.R +++ b/tests/testthat/test-auto-pre.R @@ -26,9 +26,8 @@ test_that("plan_release() works", { tempdir_remote <- withr::local_tempdir(pattern = "remote") create_remote(tempdir_remote) - ## TODO: add test for bump_version() not run? local_fledge_quiet() - bump_version() + expect_fledge_snapshot({ plan_release("next") }) diff --git a/tests/testthat/test-auto.R b/tests/testthat/test-auto.R index 5205f880..592a4e7c 100644 --- a/tests/testthat/test-auto.R +++ b/tests/testthat/test-auto.R @@ -49,23 +49,6 @@ test_that("create_release_branch() works", { }) }) -test_that("plan_release() works", { - withr::local_envvar("FLEDGE_TEST_NOGH" = "blop") - withr::local_envvar("FLEDGE_DONT_BOTHER_CRAN_THIS_IS_A_TEST" = "yes-a-test") - local_demo_project(quiet = TRUE) - - tempdir_remote <- withr::local_tempdir(pattern = "remote") - create_remote(tempdir_remote) - - local_fledge_quiet() - bump_version() - - expect_fledge_snapshot({ - plan_release("next") - }) - expect_true(gert::git_branch_exists("cran-0.0.1")) -}) - test_that("plan_release() -- force", { withr::local_envvar("FLEDGE_TEST_NOGH" = "blop") withr::local_envvar("FLEDGE_DONT_BOTHER_CRAN_THIS_IS_A_TEST" = "yes-a-test")