fix matching of packages for which the latest verison is not available

This commit is contained in:
Patrick Schratz 2024-09-03 19:55:35 +02:00
commit 8ae2c12262
Signed by: pat-s
GPG key ID: 3C6318841EF78925

View file

@ -1,4 +1,5 @@
#' Archive packages in CRAN-like repositories
#' @importFrom stringr str_split
#' @export
#' @examples
#' archive_package("AATtools", codename = "rhel9")
@ -48,7 +49,7 @@ archive_package <- function(
} else {
versions <- rev(pak::pkg_history(.x)$Version)
for (i in versions) {
if (any(grepl(i, all_versions, fixed = TRUE))) {
if (any(grepl(paste0("^", i, "$"), stringr::str_split(stringr::str_split(all_versions, "_", simplify = T)[, 2], ".tar.gz", simplify = TRUE)[, 1]))) {
index <- which(grepl(sprintf("_%s.tar.gz", i), all_versions))
old_versions <- all_versions[-index]
break