Skip to content

Commit 252d6be

Browse files
committed
keep track of seen packages
1 parent c2fd642 commit 252d6be

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

R/fetchers.R

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,12 +370,23 @@ fetchlocals <- function(local_r_pkgs) {
370370
#' from GitHub.
371371
#' @noRd
372372
fetchgits <- function(git_pkgs) {
373+
# Initialize global seen variable if it doesn't exist
374+
if (!exists(".seen_packages", envir = .GlobalEnv)) {
375+
assign(".seen_packages", character(0), envir = .GlobalEnv)
376+
}
377+
373378
if (!all(vapply(git_pkgs, is.list, logical(1)))) {
379+
if (git_pkgs$package_name %in% .seen_packages) {
380+
return("")
381+
}
382+
assign(".seen_packages", c(.seen_packages, git_pkgs$package_name), envir = .GlobalEnv)
374383
fetchgit(git_pkgs)
375384
} else if (all(vapply(git_pkgs, is.list, logical(1)))) {
376385
# Re-order list of git packages by "package name"
377386
git_pkgs <- git_pkgs[order(sapply(git_pkgs, "[[", "package_name"))]
378-
387+
# Filter out already processed packages
388+
git_pkgs <- git_pkgs[!sapply(git_pkgs, function(x) x$package_name %in% .seen_packages)]
389+
assign(".seen_packages", c(.seen_packages, sapply(git_pkgs, "[[", "package_name")), envir = .GlobalEnv)
379390
paste(lapply(git_pkgs, fetchgit), collapse = "\n")
380391
} else {
381392
stop(
@@ -417,7 +428,9 @@ fetchzips <- function(archive_pkgs) {
417428
#' @return Nix definition string for building the packages
418429
#' @noRd
419430
fetchpkgs <- function(git_pkgs, archive_pkgs) {
420-
431+
# Reset seen packages at start
432+
assign(".seen_packages", character(0), envir = .GlobalEnv)
433+
421434
# Combine git and archive package definitions
422435
paste(
423436
fetchgits(git_pkgs),

0 commit comments

Comments
 (0)