R/git.R

Defines functions git_uncommitted git_branch uses_git

uses_git <- function(path = ".") {
  dir_exists(path(path, ".git"))
}

git_branch <- function(path = ".") {
  withr::local_dir(path)

  system2("git", c("rev-parse", "--abbrev-ref", "HEAD"), stdout = TRUE)
}

git_uncommitted <- function(path = ".") {
  withr::local_dir(path)

  out <- system2("git", c("status", "--porcelain=v1"), stdout = TRUE)
  length(out) > 0
}

Try the devtools package in your browser

Any scripts or data that you put into this service are public.

devtools documentation built on Oct. 12, 2022, 1:06 a.m.