Skip to content

Commit

Permalink
Do not prompt for uninstalled dependencies.
Browse files Browse the repository at this point in the history
Fixes #203
  • Loading branch information
jimhester committed Oct 19, 2018
1 parent 268351b commit e4ac061
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

* No longer include project specific .Rprofile code in the temporary .Rprofile when
`R_REMOTES_NO_ERRORS_FROM_WARNINGS=false` (the default).
* `update.package_deps()` no longer prompts to install uninstalled
dependencies, they are always installed (#203).

# remotes 2.0.0

Expand Down
9 changes: 7 additions & 2 deletions R/deps.R
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ upgradable_packages <- function(x, upgrade, is_interactive = interactive()) {
never = return(x[0, ]),

ask = {
behind <- x$diff < CURRENT
behind <- x$diff == BEHIND

if (!any(behind)) {
return(x)
Expand Down Expand Up @@ -588,7 +588,12 @@ upgradable_packages <- function(x, upgrade, is_interactive = interactive()) {
return(x)
}

x[behind, ][pkgs %in% res, ]
uninstalled <- x$diff == UNINSTALLED

rbind(
x[uninstalled, ],
x[behind, ][pkgs %in% res, ]
)
}
)
}
28 changes: 19 additions & 9 deletions tests/testthat/test-deps.R
Original file line number Diff line number Diff line change
Expand Up @@ -373,15 +373,16 @@ test_that("resolve_upgrade works", {
test_that("upgradeable_packages works", {
object <- data.frame(
stringsAsFactors = FALSE,
package = c("dotenv", "falsy", "magrittr"),
installed = c("1.0", "1.0", NA),
available = c("1.0", "1.1", "1.0"),
diff = c(CURRENT, BEHIND, UNINSTALLED),
is_cran = c(TRUE, TRUE, TRUE)
package = c("dotenv", "falsy", "rlang", "magrittr"),
installed = c("1.0", "1.0", "abc123", NA),
available = c("1.0", "1.1", "zyx456", "1.0"),
diff = c(CURRENT, BEHIND, BEHIND, UNINSTALLED),
is_cran = c(TRUE, TRUE, FALSE, TRUE)
)
object$remote <- list(
cran_remote("dotenv", getOption("repos"), getOption("type")),
cran_remote("falsy", getOption("repos"), getOption("type")),
github_remote("rlib/rlang"),
cran_remote("magrittr", getOption("repos"), getOption("type"))
)
class(object) <- c("package_deps", "data.frame")
Expand All @@ -399,14 +400,23 @@ test_that("upgradeable_packages works", {
object)

# returns selected row to update if "ask" and is_interactive
mockery::stub(upgradable_packages, "utils::select.list", function(...) "falsy (1.0 -> 1.1) [CRAN]")
mockery::stub(upgradable_packages, "utils::select.list", function(...) "falsy (1.0 -> 1.1 ) [CRAN]")
expect_equal(upgradable_packages(object, "ask", is_interactive = TRUE),
object[object$package == "falsy", ])
object[c(
which(object$package == "magrittr"),
which(object$package == "falsy")
), ]
)

# returns selected rows to update if "ask" and is_interactive
mockery::stub(upgradable_packages, "utils::select.list", function(...) c("falsy (1.0 -> 1.1) [CRAN]", "magrittr (NA -> 1.0) [CRAN]"))
mockery::stub(upgradable_packages, "utils::select.list", function(...) c("falsy (1.0 -> 1.1 ) [CRAN]", "rlang (abc123 -> zyx456) [GitHub]"))
expect_equal(upgradable_packages(object, "ask", is_interactive = TRUE),
object[object$package %in% c("falsy", "magrittr"), ])
object[c(
which(object$package == "magrittr"),
which(object$package == "falsy"),
which(object$package == "rlang")
), ]
)

# All should be the whole object
mockery::stub(upgradable_packages, "utils::select.list", function(...) "All")
Expand Down

0 comments on commit e4ac061

Please sign in to comment.