Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Pull as part of finalize_version() #408

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
7 changes: 5 additions & 2 deletions R/api-commit-version.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
#' Commits changes to `NEWS.md` and `DESCRIPTION`, amending a previous commit
#' created by \pkg{fledge} if necessary.
#'
#' @param pull whether to fetch the remote (if it exists).
#'
#'
#' @example man/examples/commit-version.R
#'
#' @export
commit_version <- function() {
amending <- commit_version_impl()
commit_version <- function(pull = TRUE) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually the default should be FALSE I suppose

amending <- commit_version_impl(pull = pull)

#' @return Invisibly: `TRUE` if a previous commit for that version has been
#' amended, `FALSE` if not.
Expand Down
5 changes: 3 additions & 2 deletions R/api-finalize-version.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
#' Calls the following functions:
#'
#' @param push If `TRUE`, push the created tag.
#' @inheritParams commit_version
#' @example man/examples/finalize-version.R
#' @return None
#' @export
finalize_version <- function(push = FALSE) {
with_repo(finalize_version_impl(push, suggest_finalize = FALSE))
finalize_version <- function(push = FALSE, pull = push) {
with_repo(finalize_version_impl(push, suggest_finalize = FALSE, pull))
}
10 changes: 9 additions & 1 deletion R/commit-version.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
commit_version_impl <- function() {
commit_version_impl <- function(pull) {
check_only_staged(c("DESCRIPTION", news_path()))

if (has_remote_branch(gert::git_branch()) && pull) {
# is the local branch behind?
if (gert::git_ahead_behind()$behind > 0) {
# With pull = TRUE we would fetch always and always uncommit + commit if behind master
gert::git_pull(rebase = TRUE)
}
}

if (is_last_commit_bump()) {
if (fledge_chatty()) {
cli_alert("Resetting to previous commit.")
Expand Down
2 changes: 1 addition & 1 deletion R/finalize-version.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' @rdname finalize_version
#' @usage NULL
finalize_version_impl <- function(push, suggest_finalize = TRUE) {
finalize_version_impl <- function(push, suggest_finalize = TRUE, pull) {
#' @description
#' 1. [commit_version()]
force <- commit_version()
Expand Down
5 changes: 4 additions & 1 deletion man/commit_version.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/finalize_version.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.