-
Notifications
You must be signed in to change notification settings - Fork 11
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: add which "pre-minor" and "pre-major" to update_version() #412
Conversation
I added tests so you can see whether what's here is what you expected. |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
R/update-version.R
Outdated
|
||
fledge_bump_version <- function(desc, which) { | ||
if (which %in% c("patch", "minor", "major", "dev")) { | ||
desc$bump_version(which) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we forbid > 99 here? We can roll our own bumping, we won't need suppressMessages()
above too.
Perhaps:
new_version <- switch(which,
"dev" = c(major, minor, patch, (dev + 1) %||% 9000),
"patch" = {
if (patch >= 99) abort(...)
c(...)
},
"minor" = ...
)
with explicit local variables for the four components?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we forbid > 99 here
And abort if patch/minor are already higher? I had wondered about this in a comment too.
We can roll our own bumping, we won't need suppressMessages() above too.
- Actually the desc issue was solved so that's not needed anyway.
- I find it easier to separate both cases as we need to check the fourth component (dev) is present for "pre-minor" and "pre-major" (at least I assume so: one can't go from not dev to "pre-minor"/"pre-major"?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to abort if patch >= 99
, as in the code example, overall it looks like it will be simpler without desc::bump_version()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the error. Does the behavior in the test file look ok?
Why would removing
if (which %in% c("patch", "minor", "major", "dev")) {
desc$bump_version(which)
return(desc)
}
be simpler?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel the current code gets the "easiest cases" out of the way right away but I can amend further obviously.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if we bump pre-major and then pre-minor?
R/update-version.R
Outdated
if (which %in% c("patch", "minor", "major", "dev")) { | ||
suppressMessages(desc$bump_version(which), classes = "descMessage") | ||
return(desc) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should do this ourselves, because we want to error:
- in "dev", when dev >= 9999
- in "patch", when patch >= 99
- in "minor", when minor >= 99
R/update-version.R
Outdated
version_components <- get_version_components(version) | ||
|
||
if (which %in% c("patch", "minor", "major", "dev")) { | ||
version_components[["dev"]] <- switch( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found it easier to follow to use switch once per component (and to still separate the "usual" cases from pre-minor and pre-major).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I just realized we might want another option: "next"
, moving from pre-minor to minor and from pre-major to major, and to patch otherwise. Would be the default option to pre_release()
. We can do it here or open a new issue.
Do we need more tests for error behavior, e.g. pre-minor after pre-minor, pre-minor after pre-major, and other exotic cases?
Co-authored-by: Kirill Müller <krlmlr@users.noreply.github.com>
I'd also add more tests when tackling the "next" issue. |
And at some points the docs will need a diagram. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Expert nitpicking here, no clear preference.
dev = dev | ||
) | ||
new_version <- paste(version_components[!is.na(version_components)], collapse = ".") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dev = dev | |
) | |
new_version <- paste(version_components[!is.na(version_components)], collapse = ".") | |
dev = if (!is.na(dev)) dev | |
) | |
new_version <- paste(version_components, collapse = ".") |
Fix #413
Part of #401
As you will see there are two questions in the comments
and