Skip to content

Instantly share code, notes, and snippets.

@pat-s
Created July 26, 2020 08:24
Show Gist options
  • Save pat-s/13f9d72a75e6a54585d9262a8d01b3ef to your computer and use it in GitHub Desktop.
Save pat-s/13f9d72a75e6a54585d9262a8d01b3ef to your computer and use it in GitHub Desktop.
if (requireNamespace(c("callr", "git2r", "gert", "cli"), quietly = TRUE)) {
has_git = git2r::in_repository()
if (has_git && Sys.getenv("RSTUDIO") == 1) {
cli::cli_text("Running
{.code gert::git_pull(verbose = FALSE, prune = TRUE, rebase = TRUE)}
in the background.")
callr::r_bg(function() {
gert::git_pull(verbose = FALSE, prune = TRUE, rebase = TRUE)
},
stdout = out <- tempfile(), stderr = err <- tempfile())$wait()
cli::cli_text("stdout: '{readLines(out)}'")
cli::cli_text("stderr: '{readLines(err)}'")
# cat(readLines(out), sep = "\n")
# cat(readLines(err), sep = "\n")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment