diff --git a/DESCRIPTION b/DESCRIPTION index 28bd76d3..3c5574e8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -23,6 +23,7 @@ Imports: rcmdcheck, remotes (>= 2.2.0), stats, + tools, utils, withr (>= 2.4.3) Suggests: @@ -46,5 +47,5 @@ Encoding: UTF-8 Language: en-US LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 Config/testthat/edition: 3 diff --git a/R/deps_installation_proposal.R b/R/deps_installation_proposal.R index 8947d038..3cde74a6 100644 --- a/R/deps_installation_proposal.R +++ b/R/deps_installation_proposal.R @@ -130,9 +130,11 @@ new_min_cohort_deps_installation_proposal <- function(path, # nolint refs, function(x) { version <- version_from_desc(d, x$package) - if (inherits(x, "remote_ref_github") && - check_if_on_cran(x, version$op, version$op_ver) && - x$commitish == "") { + if ( + inherits(x, "remote_ref_github") && + check_if_on_cran(x, version$op, version$op_ver) && + x$commitish == "" + ) { pkgdepends::parse_pkg_ref(x$package) } else { x @@ -202,7 +204,7 @@ new_min_cohort_deps_installation_proposal <- function(path, # nolint origin = "1970-01-01" ) - ppm_repo <- get_ppm_snapshot_by_date(max_release_date) + ppm_repo <- get_ppm_snapshot_by_date(max_release_date + 1) config <- append_config(config, list("cran_mirror" = ppm_repo)) diff --git a/R/get_ref.R b/R/get_ref.R index 1a793ca2..9171cf9a 100644 --- a/R/get_ref.R +++ b/R/get_ref.R @@ -438,6 +438,19 @@ get_cran_data <- function(package) { cran_current <- pkgcache::meta_cache_list(packages = package)[, c( "type", "package", "version", "published" )] + if (all(is.na(cran_current$published))) { + # workaround of https://github.com/r-lib/pkgcache/issues/109 + if (is.null(pkgenv$cache_db)) { + pkgenv$cache_db <- tools::CRAN_package_db() + } + db <- subset(pkgenv$cache_db, Package == package) + cran_current <- data.frame( + type = "cran", + package = package, + version = db$Version, + published = as.POSIXct(db$`Date/Publication`) + ) + } # Bioc custom logic as packages in Bioconductor do not return a published date # this will be immediately obsolete if {pkgcache} starts to return a non-NA value diff --git a/R/utils.R b/R/utils.R index 8b72a9da..94d79282 100644 --- a/R/utils.R +++ b/R/utils.R @@ -4,6 +4,8 @@ .desc_field <- "Config/Needs/verdepcheck" +pkgenv <- new.env(parent = emptyenv()) + #' @importFrom pkgdepends as_pkg_dependencies default_config <- function() { list( diff --git a/tests/testthat/setup.R b/tests/testthat/setup-envvar.R similarity index 100% rename from tests/testthat/setup.R rename to tests/testthat/setup-envvar.R