#' Delete merged GitHub branches
#'
#' @return invisible(TRUE)
#' @export
git_cleanup <- function() {
system2(
paste(
# Prune remote branches that no longer exist
"git fetch -p &&",
# Delete all local branches that have been merged to main
"for branch in $(git for-each-ref --format '%(refname) %(upstream:track)'",
"refs/heads | awk '$2 == \"[gone]\" {sub(\"refs/heads/\", \"\", $1); print $1}');",
"do git branch -D $branch; done"
)
)
return(invisible(TRUE))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.