Skip to content

Commit

Permalink
feat: plan_release() calls bump_version() (#814)
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr authored Nov 22, 2024
1 parent d9c9cfb commit 92d2642
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 63 deletions.
27 changes: 17 additions & 10 deletions R/auto.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
19 changes: 18 additions & 1 deletion tests/testthat/_snaps/auto-full-cycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
+------------------+
| |
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/_snaps/auto-pre.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Code
plan_release("next")
Message
> Digesting messages from 1 commits.
> Digesting messages from 2 commits.
Output
+------------------+
| |
Expand Down
30 changes: 0 additions & 30 deletions tests/testthat/_snaps/auto.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-auto-full-cycle.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
3 changes: 1 addition & 2 deletions tests/testthat/test-auto-pre.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})
Expand Down
17 changes: 0 additions & 17 deletions tests/testthat/test-auto.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 92d2642

Please sign in to comment.