Skip to content

Commit

Permalink
feat: post_release() no longer checks if on release branch
Browse files Browse the repository at this point in the history
.
  • Loading branch information
krlmlr authored and aviator-bot committed Nov 4, 2023
1 parent 83cda24 commit d4826b7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 87 deletions.
25 changes: 4 additions & 21 deletions R/auto.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#' @param which Component of the version number to update. Supported
#' values are
#' * `"next"` (`"major"` if the current version is `x.99.99.9yz`,
#' `"minor"` if the current version is `x.y.99.za`,
#' `"patch"` otherwise),
#' `"minor"` if the current version is `x.y.99.za`,
#' `"patch"` otherwise),
#' * `"patch"`
#' * `"minor"`,
#' * `"major"`.
Expand Down Expand Up @@ -472,31 +472,14 @@ post_release <- function() {

post_release_impl <- function() {
check_only_modified(c(".Rbuildignore"))

check_post_release()
# Need PAT for creating GitHub release
check_gh_pat("repo")

# Begin extension points
# End extension points

create_github_release()

merge_main_into_post_release()

# FIXME: Check if PR open, if yes merge PR instead
release_branch <- get_branch_name()
switch_branch(get_main_branch())
pull_head()
merge_branch(release_branch)

bump_version_impl(
read_fledgling(),
"dev",
no_change_behavior = "bump",
edit = FALSE,
no_change_message = "- Resume development after CRAN release."
)
push_head()

# Begin extension points
# End extension points
}
Expand Down
65 changes: 6 additions & 59 deletions tests/testthat/_snaps/auto.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,31 +187,8 @@
Code
post_release()
Message
> Checking presence and scope of `GITHUB_PAT`.
> Creating GitHub release "v0.0.1".
> Creating GitHub release "v".
> Omitting in test.
> Switching to branch main.
> Pulling main.
Resetting main to origin/main
> Merging release branch.
i If this fails, resolve the conflict manually and push.
> Digesting messages from 2 commits.
v Found 1 NEWS-worthy entry.
-- Updating NEWS --
> Adding new entries to 'NEWS.md'.
-- Updating Version --
v Package version bumped to 0.0.1.9000.
> Added header to 'NEWS.md'.
> Committing changes.
-- Tagging Version --
> Creating tag v0.0.1.9000 with tag message derived from 'NEWS.md'.
> Pushing main.

# full cycle pre-minor

Expand Down Expand Up @@ -288,31 +265,8 @@
Code
post_release()
Message
> Checking presence and scope of `GITHUB_PAT`.
> Creating GitHub release "v0.1.0".
> Creating GitHub release "v".
> Omitting in test.
> Switching to branch main.
> Pulling main.
Resetting main to origin/main
> Merging release branch.
i If this fails, resolve the conflict manually and push.
> Digesting messages from 2 commits.
v Found 1 NEWS-worthy entry.
-- Updating NEWS --
> Adding new entries to 'NEWS.md'.
-- Updating Version --
v Package version bumped to 0.1.0.9000.
> Added header to 'NEWS.md'.
> Committing changes.
-- Tagging Version --
> Creating tag v0.1.0.9000 with tag message derived from 'NEWS.md'.
> Pushing main.

# release abandon

Expand Down Expand Up @@ -394,21 +348,15 @@

Code
post_release()
Condition
Error in `check_post_release()`:
! The main branch contains newsworthy commits.
i Run `fledge::bump_version()` on the main branch.
Message
> Omitting in test.

---

Code
post_release()
Message
> Omitting in test.
Condition
Error in `merge_main_into_post_release()`:
! Merging the main branch into the release branch failed.
i Resolve the conflict manually and push.

# full cycle, add more to main NO PUSH

Expand Down Expand Up @@ -436,7 +384,6 @@

Code
post_release()
Condition
Error in `check_post_release()`:
! Local main branch ahead by 1 commit.
Message
> Omitting in test.

18 changes: 11 additions & 7 deletions tests/testthat/test-auto.R
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,16 @@ test_that("full cycle", {
)
expect_equal(nrow(gert::git_status()), 0)

gert::git_branch_checkout("main")
expect_equal(nrow(gert::git_status()), 0)

## post release ----
withr::local_envvar("FLEDGE_TEST_NOGH" = "no-github-no-mocking-needed-yay")
expect_snapshot(post_release())
expect_equal(nrow(gert::git_status()), 0)
expect_equal(gert::git_branch(), "main")
expect_setequal(
gert::git_tag_list()[["name"]],
c("v0.0.0.9001", "v0.0.1", "v0.0.1.9000")
c("v0.0.0.9001", "v0.0.1")
)
})

Expand Down Expand Up @@ -232,14 +234,16 @@ test_that("full cycle pre-minor", {
)
expect_equal(nrow(gert::git_status()), 0)

gert::git_branch_checkout("main")
expect_equal(nrow(gert::git_status()), 0)

## post release ----
withr::local_envvar("FLEDGE_TEST_NOGH" = "no-github-no-mocking-needed-yay")
expect_snapshot(post_release())
expect_equal(nrow(gert::git_status()), 0)
expect_equal(gert::git_branch(), "main")
expect_setequal(
gert::git_tag_list()[["name"]],
c("v0.0.99.9000", "v0.1.0", "v0.1.0.9000")
c("v0.0.99.9000", "v0.1.0")
)
})

Expand Down Expand Up @@ -334,14 +338,14 @@ test_that("full cycle, add more to main", {

## post release ----
withr::local_envvar("FLEDGE_TEST_NOGH" = "no-github-no-mocking-needed-yay")
expect_snapshot(error = TRUE, post_release())
expect_snapshot(post_release())

gert::git_branch_checkout("main")
shut_up_fledge(fledge::bump_version())
gert::git_push()
gert::git_branch_checkout("cran-0.0.1")

expect_snapshot(error = TRUE, post_release())
expect_snapshot(post_release())
})

test_that("full cycle, add more to main NO PUSH", {
Expand Down Expand Up @@ -398,5 +402,5 @@ test_that("full cycle, add more to main NO PUSH", {

## post release ----
withr::local_envvar("FLEDGE_TEST_NOGH" = "no-github-no-mocking-needed-yay")
expect_snapshot(error = TRUE, post_release())
expect_snapshot(post_release())
})

0 comments on commit d4826b7

Please sign in to comment.