Skip to content

Commit

Permalink
Don't update suggested dependencies (#1752)
Browse files Browse the repository at this point in the history
Fixes #1749
  • Loading branch information
hadley authored Jan 25, 2023
1 parent 275dc55 commit 9db9ab7
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 20 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# usethis (development version)

* `use_latest_dependencies()` no longer affects `Suggests` since those
dependencies are not enforced (#1749).

* `use_release_issue()` will now remind you to check/close the milestone
corresponding to the release, if it exists (#1642).

Expand Down
7 changes: 4 additions & 3 deletions R/latest-dependencies.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#' Use "latest" versions of all dependencies
#'
#' Pins minimum versions of dependencies to latest ones (as determined by `source`).
#' Useful for the tidyverse package, but should otherwise be used with extreme care.
#' Pins minimum versions of all `Imports` and `Depends` dependencies to latest
#' ones (as determined by `source`). Useful for the tidyverse package, but
#' should otherwise be used with extreme care.
#'
#' @keywords internal
#' @export
Expand All @@ -27,7 +28,7 @@ use_latest_dependencies <- function(overwrite = TRUE, source = c("CRAN", "local"

update_versions <- function(deps, overwrite = TRUE, source = c("CRAN", "local")) {
baserec <- base_and_recommended()
to_change <- !deps$package %in% c("R", baserec)
to_change <- !deps$package %in% c("R", baserec) & deps$type != "Suggests"
if (!overwrite) {
to_change <- to_change & deps$version == "*"
}
Expand Down
5 changes: 3 additions & 2 deletions man/use_latest_dependencies.Rd

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

43 changes: 28 additions & 15 deletions tests/testthat/test-latest-dependencies.R
Original file line number Diff line number Diff line change
@@ -1,28 +1,41 @@
test_that("use_tidy_versions() specifies a version for dependencies", {
test_that("sets version for imports & depends dependencies", {
skip_on_cran()
withr::local_options(list(repos = c(CRAN = "https://cloud.r-project.org")))

pkg <- create_local_package()
create_local_package()
use_package("usethis")
use_package("desc")
use_package("withr", "Suggests")
use_package("gh", "Suggests")
use_package("desc", "Depends")
use_latest_dependencies()
desc <- read_utf8(proj_path("DESCRIPTION"))
desc <- grep("usethis|desc|withr|gh", desc, value = TRUE)
expect_true(all(grepl("\\(>= [0-9.]+\\)", desc)))

deps <- proj_deps()
expect_equal(
deps$version[deps$package %in% c("usethis", "desc")] == "*",
c(FALSE, FALSE)
)
})

test_that("doesn't affect suggests", {
skip_on_cran()
withr::local_options(list(repos = c(CRAN = "https://cloud.r-project.org")))

create_local_package()
use_package("cli", "Suggests")
use_latest_dependencies()

deps <- proj_deps()
expect_equal(deps$version[deps$package == "cli"], "*")
})

test_that("use_tidy_versions() does nothing for a base package", {
test_that("does nothing for a base package", {
skip_on_cran()
withr::local_options(list(repos = c(CRAN = "https://cloud.r-project.org")))

## if we ever depend on a recommended package, could beef up this test a bit
pkg <- create_local_package()
create_local_package()
use_package("tools")
use_package("stats", "Suggests")
# if usethis ever depends on a recommended package, we could test that here too
use_latest_dependencies()
desc <- read_utf8(proj_path("DESCRIPTION"))
desc <- grep("tools|stats", desc, value = TRUE)
expect_false(any(grepl("\\(>= [0-9.]+\\)", desc)))

deps <- proj_deps()
expect_equal(deps$version[deps$package == "tools"], "*")
})

0 comments on commit 9db9ab7

Please sign in to comment.