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: Improve bump_version() behavior in the absence of changes #323

Merged
merged 17 commits into from
May 17, 2022

Conversation

maelle
Copy link
Member

@maelle maelle commented May 13, 2022

Fix #316
Fix #307

@maelle maelle marked this pull request as ready for review May 13, 2022 13:20
@maelle maelle changed the title Improve bump_version() behavior in the absence of changes feat: Improve bump_version() behavior in the absence of changes May 13, 2022
@maelle maelle requested a review from krlmlr May 13, 2022 14:01
Copy link
Contributor

@krlmlr krlmlr left a comment

Choose a reason for hiding this comment

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

Thanks, I like the tests a lot. Let's do another pass.

R/bump-version.R Outdated Show resolved Hide resolved
R/bump-version.R Outdated
#' @description
#' 1. Verify that the current branch is the main branch.
check_main_branch()
#' 1. Check there were changes since the last version.no_change()

This comment was marked as duplicate.

R/api-bump-version.R Outdated Show resolved Hide resolved
check_which(which)

no_change_behavior <- match.arg(no_change_behavior, choices = c("bump", "noop", "fail"))

This comment was marked as duplicate.

R/bump-version.R Outdated
@@ -78,3 +93,7 @@ get_main_branch_config <- function() {
global <- init[init$level == "global"]
return(global$value)
}

no_change <- function() {
nrow(default_commit_range()) == 1
Copy link
Contributor

Choose a reason for hiding this comment

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

Why 1? Can you please add a comment? Should we do <= 1 for safety?

@@ -22,7 +22,7 @@ collect_news <- function(messages) {
unlist()

if (length(message_items) == 0) {
if (length(range) <= 1) {
if (length(messages) <= 1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The logic seems repeated here. Should no_change() get a messages argument?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've changed the variable names to clarify that we are looking for newsworthy_items among messages.
Even if no_change() was run before getting to this point, if the argument no_change_behavior could mean we arrive at this point.
But maybe in the case there's less than or 1 message the function should exit earlier, is this what you mean?

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we have no_change() handle the <= 1 comparison, so that this logic is centralized, if it makes sense?

@@ -22,7 +22,7 @@ collect_news <- function(messages) {
unlist()

if (length(message_items) == 0) {
if (length(range) <= 1) {
if (length(messages) <= 1) {

This comment was marked as duplicate.

tests/testthat/test-bump_version.R Outdated Show resolved Hide resolved
tests/testthat/test-bump_version.R Outdated Show resolved Hide resolved
tests/testthat/_snaps/bump_version.md Show resolved Hide resolved
R/update-news.R Show resolved Hide resolved
@maelle maelle requested a review from krlmlr May 16, 2022 08:52
Copy link
Contributor

@krlmlr krlmlr left a comment

Choose a reason for hiding this comment

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

Thanks, looks great!

@maelle maelle merged commit 438a946 into main May 17, 2022
@maelle maelle deleted the no-change-behavior branch May 17, 2022 11:05
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

where does range come from Add noop argument (or similar) to bump_version()
2 participants