diff --git a/DESCRIPTION b/DESCRIPTION index 6c26145..bc35886 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -6,7 +6,7 @@ URL: https://spades-project.predictiveecology.org/, https://github.com/PredictiveEcology/SpaDES.project Date: 2024-10-22 -Version: 0.1.0.9010 +Version: 0.1.0.9012 Authors@R: c( person("Eliot J B", "McIntire", email = "eliot.mcintire@nrcan-rncan.gc.ca", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-6914-8316")), diff --git a/R/setupProject.R b/R/setupProject.R index e31664b..7f2a9b8 100644 --- a/R/setupProject.R +++ b/R/setupProject.R @@ -1382,19 +1382,11 @@ setupModules <- function(name, paths, modules, inProject, useGit = getOption("Sp reportBranch <- TRUE # if (!grepl("master|main|HEAD", split$br)) { - prev <- setwd(file.path(paths[["modulePath"]], split$repo)) - curBr <- gert::git_branch() + # prev <- setwd(file.path(paths[["modulePath"]], split$repo)) + # curBr <- gert::git_branch() # cmd <- "git rev-parse --abbrev-ref HEAD" # curBr <- system(cmd, intern = TRUE) - if (!identical(split$br, curBr)) { - prev <- setwd(file.path(paths[["modulePath"]], split$repo)) - gert::git_branch_checkout(split$br) - # cmd <- paste0("git checkout ", split$br) - # system(cmd) - reportBranch <- FALSE - } - gert::git_pull() # } # cmd <- paste0("git pull") # system(cmd) @@ -1402,19 +1394,29 @@ setupModules <- function(name, paths, modules, inProject, useGit = getOption("Sp if (reportBranch) messageVerbose("\b ... on ", split$br, " branch") } else { - if (nzchar(Sys.which("git"))) { - cmd <- paste0("git submodule init") - system(cmd) + submod <- file.path(basename(paths[["modulePath"]]), split$repo) + gert::git_submodule_init(submod)#) + out <- try(gert::git_submodule_fetch(submodule = submod)) + if (is(out, 'try-error')) { cmd <- paste0("git submodule update --recursive") system(cmd) - } else { - stop("To use git submodules, ", .messages$pleaseInstall()) } - # messageVerbose("module exists at ", localPath, "; not cloning", verbose = verbose) + } - }) - messageVerbose("You will likely have to commit changes to git repository now", verbose = verbose) + # prev <- setwd(file.path(paths[["modulePath"]], split$repo)) + # curBr <- gert::git_branch() + # if (!identical(split$br, curBr)) { + # prev <- setwd(file.path(paths[["modulePath"]], split$repo)) + # gert::git_submodule_set_to(submod, ref = split$br) + # # cmd <- paste0("git checkout ", split$br) + # # system(cmd) + # reportBranch <- FALSE + # } + gert::git_pull() + + }) + # messageVerbose("You will likely have to commit changes to git repository now", verbose = verbose) } if (is.character(useGit) && isLocalGitRepoAlready %in% FALSE) {