fix: fix tag parsing for 'latest'

This commit is contained in:
Patrick Schratz 2024-11-05 17:20:44 +01:00
commit 7797efc8c5
Signed by: pat-s
GPG key ID: 3C6318841EF78925

View file

@ -72,22 +72,23 @@ build_binary_package <- function(package_name, tag = NULL, codename = NULL,
gert::git_config_global_set("advice.detachedHead", "false")
if (tag == "latest" || is.null(tag)) {
if (is.null(tag) || tag == "latest") {
gert::git_clone(sprintf("https://github.com/cran/%s", package_name),
path = sprintf("%s/%s", tempdir(), "tmp1"),
verbose = FALSE
)
# Retrieve all tags
all_tags <- gert::git_tag_list(repo = sprintf("%s/%s", tempdir(), "tmp1"))
# filter out tags that start with R- (= non-valid ones)
all_tags <- all_tags[!grepl("R-", all_tags$name), ]
unlink(sprintf("%s/%s", tempdir(), "tmp1"), force = TRUE, recursive = TRUE)
tag <- all_tags$name
# gert cannot sort by date (which is a problem for properly sorting tags like 1.0-10 and others)
if (tag == "latest") {
system("git tag --sort=-creatordate | head -1")
}
if (!is.null(tag) && tag == "latest") {
tag = system("git tag --sort=-creatordate | head -1", intern = TRUE)
} else {
# Retrieve all tags
all_tags <- gert::git_tag_list(repo = sprintf("%s/%s", tempdir(), "tmp1"))
# filter out tags that start with R- (= non-valid ones)
all_tags <- all_tags[!grepl("R-", all_tags$name), ]
unlink(sprintf("%s/%s", tempdir(), "tmp1"), force = TRUE, recursive = TRUE)
tag <- all_tags$name
}
package_name <- rep(package_name, length(tag))
}