Skip to content

Commit

Permalink
use full lockfile records in checkout (closes #1969)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinushey committed Aug 16, 2024
1 parent 9e30e67 commit 264fb3b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
18 changes: 9 additions & 9 deletions R/checkout.R
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 264fb3b

Please sign in to comment.