Skip to content

Commit f64f322

Browse files
only push tag after merge on merge commit
1 parent 7a118ef commit f64f322

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

R/release.R

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,31 +43,25 @@ release_gh <- function(bump = "dev", is_cran = bump != "dev") {
4343
purrr::walk(path_template_config, update_rev_in_config,
4444
new_version = new_version
4545
)
46-
last_release <- call_and_capture("git", "tag -l --sort=-taggerdate")$stdout[1]
4746

47+
last_release <- git_last_release()
4848
cli::cli_alert_success("Updated version in default config.")
49-
msg1 <- glue::glue("Release {new_version}, see NEWS.md for details.")
50-
msg2 <- glue::glue(
51-
"Diff to previous release: ",
52-
"https://github.com/lorenzwalthert/precommit/compare/",
53-
"{last_release}...{new_version}"
54-
)
5549
sys_call(
5650
"git",
5751
glue::glue(
5852
'commit DESCRIPTION {paste0(path_template_config, collapse = " ")} ',
59-
'-m "{msg1}" -m "{msg2}"'
53+
'-m "{release_msg1(last_release, new_version)}"'
6054
),
6155
env = "SKIP=spell-check,consistent-release-tag"
6256
)
6357
cli::cli_alert_success("Committed DESCRIPTION and config template")
64-
sys_call("git", glue::glue('tag -a {new_version} -m "{msg1}" -m "{msg2}"'))
58+
if (!is_cran) {
59+
60+
}
6561
sys_call("./inst/hooks/local/consistent-release-tag.R", "--release-mode")
6662
cli::cli_alert_success("Tagged last commit with release version.")
6763
if (!is_cran) {
68-
sys_call("git", glue::glue("push origin {new_version}"),
69-
env = "SKIP=consistent-release-tag"
70-
)
64+
git_tag_release(last_release, new_version)
7165
}
7266

7367
sys_call("git", glue::glue("push"),
@@ -84,6 +78,24 @@ release_gh <- function(bump = "dev", is_cran = bump != "dev") {
8478
}
8579
}
8680

81+
git_tag_release <- function(last_release, new_version) {
82+
sys_call("git", glue::glue('tag -a {new_version} -m "{release_msg(last_release, new_version)}"'))
83+
}
84+
85+
git_last_release <- function() {
86+
call_and_capture("git", "tag -l --sort=-taggerdate")$stdout[1]
87+
}
88+
89+
release_msg <- function(last_release, new_version) {
90+
glue::glue(
91+
"Release {new_version}, see NEWS.md for details.\n\n",
92+
"Diff to previous release: ",
93+
"https://github.com/lorenzwalthert/precommit/compare/",
94+
"{last_release}...{new_version}"
95+
)
96+
}
97+
98+
8799
#' Complete the release
88100
#'
89101
#' Bumps the version to devel.
@@ -104,6 +116,9 @@ release_complete <- function(ask = TRUE, is_cran = ask, tag = NULL) {
104116
if (substr(tag, 1, 1) != "v") {
105117
rlang::abort("tag must start with v.")
106118
}
119+
git_tag_release(
120+
last_release = git_last_release(), new_version = tag
121+
)
107122
sys_call("git", glue::glue("push origin {tag}"))
108123
}
109124
autoupdate() # only updates if tag is on the main branch

0 commit comments

Comments
 (0)