Open graceannobrien opened 8 months ago
Example yaml (from-old.yaml)
from-old.yaml
pk_da: from: old-repo/script/data-assembly/pk-da.Rmd to: script/data-assembly/pk-da.Rmd
Example code to loop through from-old.yaml:
user <- "username" files_to_grab <- yaml::read_yaml(here::here("script", "from-old.yaml")) for(file.i in names(files_to_grab)) { if(file.exists(files_to_grab[[file.i]]$to)){next} command.i <- glue::glue( "svn export svn+ssh://{user}@mc1.metrumrg.com/common/repo/{files_to_grab[[file.i]]$from} {files_to_grab[[file.i]]$to}" ) system(command.i) }
Example QC helper:
qc_helper <- function(.file, .username){ from_old <- yaml::read_yaml(here::here("script/from-old.yaml")) %>% bind_rows() .from <- from_old %>% filter(to == .file) %>% pull(from) if(length(.from) == 0){ stop(.file, " not found in yaml under 'to'") } from_temp <- tempfile(fileext = paste0(".", tools::file_ext(.from))) try(suppressWarnings(file.remove(from_temp))) svn_command <- glue::glue("svn export svn+ssh://{.username}@mc1.metrumrg.com/common/repo/{.from} {from_temp}") try_command <- try(system(svn_command)) if(inherits(try_command, "try-error")){ stop("Command ", svn_command) } diffobj::diffFile( target = from_temp, current = .file, color.mode = "rgb", mode = "sidebyside", tar.banner = paste0("Old - ", basename(.file)), cur.banner = paste0("New - ", basename(.file)) ) }
Example yaml (
from-old.yaml
)Example code to loop through
from-old.yaml
:Example QC helper: