Description Usage Arguments Value Examples
View source: R/walk_git.R View source: R/map_git.R
Apply a Git command to each path
.
1 |
path |
Path to one or multiple Git repos. |
command |
A Git command, e.g. "status" or "log –oneline -n 1". |
verbose |
Print Git's output? |
stop_on_error |
If Git fails, do you want an R error? |
... |
Other arguments passed to system. |
walk_git()
is called for its side effect; it returns path
invisibly.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | library(magrittr)
# helper
walk <- function(x, f, ...) {
lapply(x, f, ...)
invisible(x)
}
repos <- file.path(tempdir(), paste0("repo", 1:2))
repos %>% walk(dir.create)
# Fails because the repo isn't initialized
repos %>%
walk_git("status") %>%
try()
# Don't throw an error
repos %>%
walk_git("status", stop_on_error = FALSE)
repos %>% walk_git("init")
repos %>% walk_git("status")
repos %>% walk_git("status", verbose = TRUE)
repos %>%
walk_git("add .") %>%
walk_git("commit -m 'Initialize' --allow-empty") %>%
walk_git("log --oneline -n 1", verbose = TRUE)
# Cleanup
walk(repos, unlink, recursive = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.