Skip to content

Commit

Permalink
feat: plan_release() pulls the current branch (#831)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: krlmlr <[email protected]>
  • Loading branch information
3 people authored Nov 24, 2024
1 parent c244ed9 commit 1714265
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 5 deletions.
7 changes: 5 additions & 2 deletions R/auto.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,24 @@ plan_release <- function(
which = c("pre-patch", "pre-minor", "pre-major", "next", "patch", "minor", "major"),
force = FALSE
) {
which <- arg_match(which)

local_repo()
check_main_branch("plan_release()")
check_only_modified(character())
check_gitignore("cran-comments.md")
pull_head()

check_suggested(
c("job", "devtools", "rhub", "urlchecker", "pkgbuild", "foghorn"),
"plan_release"
)

which <- arg_match(which)
if (which == "next") {
which <- guess_next()
}

local_options(usethis.quiet = TRUE)
local_repo()

plan_release_impl(which, force)
}
Expand Down
4 changes: 4 additions & 0 deletions R/utils-git.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ check_main_branch <- function(reason, alternative = NULL) {
fast_git_add <- function(path) {
stopifnot(system2("git", c("add", "--", path)) == 0)
}

scrub_hash <- function(x) {
gsub("[0-9a-f]{40}", "sha", x)
}
2 changes: 2 additions & 0 deletions tests/testthat/_snaps/auto-full-cycle-main-nopush.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
Code
plan_release("next")
Message
> Pulling main.
Resetting main to origin/main
> Digesting messages from 1 commits.
Output
+------------------+
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/_snaps/auto-full-cycle-main.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
Code
plan_release("next")
Message
> Pulling main.
Resetting main to origin/main
> Digesting messages from 1 commits.
Output
+------------------+
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/_snaps/auto-full-cycle-pre.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
Code
plan_release("next")
Message
> Pulling main.
Resetting main to origin/main
> Digesting messages from 1 commits.
Output
+------------------+
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/_snaps/auto-full-cycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
Code
plan_release("next")
Message
> Pulling main.
Resetting main to sha
> Digesting messages from 3 commits.
v Found 1 NEWS-worthy entry.
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/_snaps/auto-pre.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
Code
plan_release("next")
Message
> Pulling main.
Resetting main to origin/main
> Digesting messages from 2 commits.
Output
+------------------+
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/_snaps/auto-release-abandon.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
Code
plan_release()
Message
> Pulling main.
Resetting main to origin/main
> Digesting messages from 1 commits.
Output
+------------------+
Expand Down Expand Up @@ -44,6 +46,8 @@
Code
plan_release(force = FALSE)
Message
> Pulling main.
Resetting main to origin/main
> Digesting messages from 1 commits.
Condition
Error in `check_release_branch()`:
Expand All @@ -55,6 +59,8 @@
Code
plan_release(force = TRUE)
Message
> Pulling main.
Resetting main to origin/main
> Digesting messages from 1 commits.
Output
+------------------+
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/_snaps/auto.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
Code
plan_release()
Message
> Pulling main.
Resetting main to sha
> Digesting messages from 1 commits.
Condition
Error in `check_release_branch()`:
Expand All @@ -33,6 +35,8 @@
Code
plan_release(force = TRUE)
Message
> Pulling main.
Resetting main to sha
> Digesting messages from 1 commits.
Output
+------------------+
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-auto-full-cycle.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ test_that("full cycle", {
## init release ----
withr::local_envvar("FLEDGE_TEST_NOGH" = "no-github-no-mocking-needed-yay")
withr::local_envvar("FLEDGE_DONT_BOTHER_CRAN_THIS_IS_A_TEST" = "yes-a-test")
expect_fledge_snapshot({
expect_fledge_snapshot(transform = scrub_hash, {
plan_release("next")
})
expect_equal(gert::git_branch(), "cran-0.0.1")
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-auto.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ test_that("plan_release() -- force", {

gert::git_branch_create("cran-0.0.0.9900", checkout = FALSE)

expect_fledge_snapshot(error = TRUE, {
expect_fledge_snapshot(transform = scrub_hash, error = TRUE, {
plan_release()
})
expect_fledge_snapshot({
expect_fledge_snapshot(transform = scrub_hash, {
plan_release(force = TRUE)
})
expect_true(gert::git_branch_exists("cran-0.0.0.9900"))
Expand Down

0 comments on commit 1714265

Please sign in to comment.