remote_path <- normalizePath(
path = file.path(Sys.getenv()[["OneDrive"]], "Desktop\\test_repo"),
# path = file.path(Sys.getenv()[["OneDrive"]], "Desktop\\test_repo"),
winslash = "/",
mustWork = FALSE
)
local_path <- normalizePath(
path = file.path(Sys.getenv()[["USERPROFILE"]], "Software\\Git Local\\test_repo"),
# path = file.path(Sys.getenv()[["USERPROFILE"]], "Software\\Git Local\\test_repo"),
winslash = "/",
mustWork = FALSE
)
files_to_copy_path <- list.files(" ", full.names = TRUE)
if (!dir.exists(remote_path)) {
dir.create(remote_path)
cli::cli_alert_success(paste0(remote_path, " created!"))
} else {
cli::cli_alert_info(paste0(remote_path, " already exists!"))
}
remote_terminal_id <- rstudioapi::terminalExecute(
command = "git init --bare",
workingDir = remote_path
)
while (is.null(rstudioapi::terminalExitCode(remote_terminal_id))) {
Sys.sleep(0.1)
}
if (!dir.exists(local_path)) {
dir.create(local_path)
cli::cli_alert_success(paste0(local_path, " created!"))
} else {
cli::cli_alert_info(paste0(local_path, " already exists!"))
}
local_terminal_id_init <- rstudioapi::terminalExecute(
command = "git init",
workingDir = local_path
)
while (is.null(rstudioapi::terminalExitCode(local_terminal_id_init))) {
Sys.sleep(0.1)
}
rstudioapi::initializeProject(local_path)
purrr::walk(rstudioapi::terminalList(), rstudioapi::terminalKill)
file.copy(
from = files_to_copy_path,
to = local_path
)