-
Notifications
You must be signed in to change notification settings - Fork 286
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
Let use_package()
decrement a package dependency.
#2043
Changes from 2 commits
6d8e65d
692c8cd
ceef905
db7d98e
548e5ab
4278d10
91a7cad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,19 +62,19 @@ use_dependency <- function(package, type, min_version = NULL) { | |
"!" = "Package {.pkg {package}} is already listed in | ||
{.field {existing_type}} in DESCRIPTION; no change made." | ||
)) | ||
} else if (delta == 0 && !is.null(min_version)) { | ||
} else if (delta == 0 && version_spec(version) != version_spec(existing_version)) { | ||
# change version | ||
upgrade <- existing_version == "*" || | ||
numeric_version(min_version) > version_spec(existing_version) | ||
if (upgrade) { | ||
ui_bullets(c( | ||
"v" = "Increasing {.pkg {package}} version to {.val {version}} in | ||
DESCRIPTION." | ||
)) | ||
desc$set_dep(package, type, version = version) | ||
desc$write() | ||
changed <- TRUE | ||
} | ||
direction <- ifelse(version_spec(version) > version_spec(existing_version), | ||
"Increasing", "Decreasing") | ||
|
||
ui_bullets(c( | ||
"v" = "{.drn {direction}} {.pkg {package}} version to {.val {version}} in | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not familiar with the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just tried to replicate the same logic as in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something like For pure interpolation (which is the goal with You can learn more about this in the cli package: https://cli.r-lib.org/reference/inline-markup.html. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for pointing this out, and thanks again for your time and patience today! |
||
DESCRIPTION." | ||
)) | ||
desc$set_dep(package, type, version = version) | ||
desc$write() | ||
changed <- TRUE | ||
|
||
} else if (delta > 0) { | ||
# moving from, e.g., Suggests to Imports | ||
ui_bullets(c( | ||
|
@@ -96,6 +96,7 @@ r_version <- function() { | |
} | ||
|
||
version_spec <- function(x) { | ||
if (x == "*") x <- "0" | ||
x <- gsub("(<=|<|>=|>|==)\\s*", "", x) | ||
numeric_version(x) | ||
} | ||
|
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.
Can you change this to an
if () ... else
? I generally reserveifelse()
for vectorized situations.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.
Sure!