diff --git a/NEWS.md b/NEWS.md index a38b0f068..3538cf5e6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,9 @@ # renv (development version) +* Fixed an issue where `renv::checkout()` omitted some fields from lockfile + records when using `actions = c("snapshot", "restore")`. (#1969) + * `renv` gains the function `renv::retrieve()`, which can be used to download packages without installing them. This is primarily useful in CI / CD scenarios, where you might want to download packages in a single stage before attempting diff --git a/R/checkout.R b/R/checkout.R index d425a10df..99b5d103d 100644 --- a/R/checkout.R +++ b/R/checkout.R @@ -1,7 +1,7 @@ #' Checkout a repository #' -#' `renv::checkout()` can be used to retrieve the latest-availabe packages from +#' `renv::checkout()` can be used to retrieve the latest-available packages from #' a (set of) package repositories. #' #' `renv::checkout()` is most useful with services like the Posit's @@ -38,7 +38,7 @@ #' based on the latest versions of the packages available from `repos`, or #' "restore" if you'd like to install those packages. You can use #' `c("snapshot", "restore")` if you'd like to generate a lockfile and -#' install those packages in the same step. +#' install those packages in a single call. #' #' @examples #' \dontrun{ @@ -88,13 +88,13 @@ checkout <- function(repos = NULL, lockfile <- renv_lockfile_init(project) lockfile$Packages <- records - # perform requested actions - for (action in actions) { - case( - action == "snapshot" ~ renv_lockfile_write(lockfile, file = renv_lockfile_path(project)), - action == "restore" ~ restore(lockfile = lockfile, clean = clean), - ~ stopf("unrecognized action '%s'") - ) + if ("restore" %in% actions) { + restore(lockfile = lockfile, clean = clean) + lockfile <- snapshot(packages = packages, lockfile = NULL) + } + + if ("snapshot" %in% actions) { + renv_lockfile_write(lockfile, file = renv_lockfile_path(project)) } invisible(lockfile)