diff --git a/R/auto.R b/R/auto.R index c83d1081..3624c217 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) { @@ -123,15 +130,14 @@ plan_release_impl <- function(which, force) { push_to_new(remote_name, force) if (fledge_chatty()) { - cli_alert("Opening draft pull request with contents from {.file cran-comments.md}.") + cli_alert("Opening pull request with instructions.") } + create_pull_request(get_branch_name(), main_branch, remote_name, force) + has_src <- pkgbuild::pkg_has_src() if (is_installed("job") && rstudioapi::isAvailable() && !nzchar(Sys.getenv("FLEDGE_TEST_NOGH"))) { - inject(job::empty(title = "create_pull_request", { - asNamespace("fledge")$create_pull_request(!!get_branch_name(), !!main_branch, !!remote_name, !!force) - })) inject(job::empty(title = "check_win_devel", { devtools::check_win_devel() })) @@ -162,8 +168,6 @@ plan_release_impl <- function(which, force) { cli_end() } } else { - create_pull_request(get_branch_name(), main_branch, remote_name, force) - # user action items if (fledge_chatty()) { cli_h1("3. User Action Items") @@ -405,7 +409,7 @@ get_cransplainer_update <- function(package) { cransplainer <- paste0( "- [x] ", checked_on, ", problems found: ", url, "\n", - paste0("- [ ] ", details$result, ": ", details$flavors, "\n", details$message, collapse = "\n") + paste0("- [ ] ", details$result, ": ", details$flavors, "\n", substr(details$message, 1, 2000), collapse = "\n") ) paste0(cransplainer, "\n\nCheck results at: ", url) @@ -752,8 +756,7 @@ create_pull_request <- function(release_branch, main_branch, remote_name, force) ) } - # FIXME: Use response from gh() call to open URL - usethis::pr_view() + utils::browseURL(pr[["html_url"]]) } # FIXME: Align with new-style release diff --git a/tests/testthat/_snaps/auto-full-cycle-main-nopush.md b/tests/testthat/_snaps/auto-full-cycle-main-nopush.md index bac63369..9b19ca18 100644 --- a/tests/testthat/_snaps/auto-full-cycle-main-nopush.md +++ b/tests/testthat/_snaps/auto-full-cycle-main-nopush.md @@ -19,7 +19,7 @@ -- 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'. + > Opening pull request with instructions. -- 3. User Action Items -------------------------------------------------------- * Run `devtools::check_win_devel()`. diff --git a/tests/testthat/_snaps/auto-full-cycle-main.md b/tests/testthat/_snaps/auto-full-cycle-main.md index 4cfd6514..c2217158 100644 --- a/tests/testthat/_snaps/auto-full-cycle-main.md +++ b/tests/testthat/_snaps/auto-full-cycle-main.md @@ -19,7 +19,7 @@ -- 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'. + > Opening pull request with instructions. -- 3. User Action Items -------------------------------------------------------- * Run `devtools::check_win_devel()`. diff --git a/tests/testthat/_snaps/auto-full-cycle-pre.md b/tests/testthat/_snaps/auto-full-cycle-pre.md index ca2a661f..a74c4b3c 100644 --- a/tests/testthat/_snaps/auto-full-cycle-pre.md +++ b/tests/testthat/_snaps/auto-full-cycle-pre.md @@ -19,7 +19,7 @@ -- 2. Opening Pull Request for release branch ---------------------------------- > Pushing cran-0.1.0 to remote origin. - > Opening draft pull request with contents from 'cran-comments.md'. + > Opening pull request with instructions. -- 3. User Action Items -------------------------------------------------------- * Run `devtools::check_win_devel()`. diff --git a/tests/testthat/_snaps/auto-full-cycle.md b/tests/testthat/_snaps/auto-full-cycle.md index 1f8a441c..378a9537 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 +------------------+ | | @@ -19,7 +36,7 @@ -- 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'. + > Opening pull request with instructions. -- 3. User Action Items -------------------------------------------------------- * Run `devtools::check_win_devel()`. diff --git a/tests/testthat/_snaps/auto-pre.md b/tests/testthat/_snaps/auto-pre.md index abbcf145..cb315f75 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 +------------------+ | | @@ -28,7 +28,7 @@ -- 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'. + > Opening pull request with instructions. -- 3. User Action Items -------------------------------------------------------- * Run `devtools::check_win_devel()`. diff --git a/tests/testthat/_snaps/auto-release-abandon.md b/tests/testthat/_snaps/auto-release-abandon.md index 8f03d3d4..0ff77516 100644 --- a/tests/testthat/_snaps/auto-release-abandon.md +++ b/tests/testthat/_snaps/auto-release-abandon.md @@ -19,7 +19,7 @@ -- 2. Opening Pull Request for release branch ---------------------------------- > Pushing cran-0.0.0.9900 to remote origin. - > Opening draft pull request with contents from 'cran-comments.md'. + > Opening pull request with instructions. -- 3. User Action Items -------------------------------------------------------- * Run `devtools::check_win_devel()`. @@ -71,7 +71,7 @@ -- 2. Opening Pull Request for release branch ---------------------------------- > Pushing cran-0.0.0.9900 to remote origin. - > Opening draft pull request with contents from 'cran-comments.md'. + > Opening pull request with instructions. -- 3. User Action Items -------------------------------------------------------- * Run `devtools::check_win_devel()`. diff --git a/tests/testthat/_snaps/auto.md b/tests/testthat/_snaps/auto.md index 0f86b4e0..e406668b 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 @@ -79,7 +49,7 @@ -- 2. Opening Pull Request for release branch ---------------------------------- > Pushing cran-0.0.0.9900 to remote origin. - > Opening draft pull request with contents from 'cran-comments.md'. + > Opening pull request with instructions. -- 3. User Action Items -------------------------------------------------------- * Run `devtools::check_win_devel()`. 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")