getGitRoot: Are we in a 'git' repository?

View source: R/inGit.R

getGitRootR Documentation

Are we in a git repository?

Description

The getGitRoot() function recursively ascends the filesystem tree from the given directory until it either finds a directory .git, or the top-level directory to abort the search. The root directory of the git repository is returned, with an exmpty string in the case of no repository. The inGit() function turns this into boolean predicate returning either TRUE or FALSE.

Usage

getGitRoot(cwd = getwd())

inGit(cwd = getwd())

Arguments

cwd

The start directory, default to the current working directory

Value

For getGitRoot(), the path of the directory containing the .git directory, ie the project root directory, or an empty string in case the search started outside a git directory. The inGit() function returns a boolean as to whether a git repository was found or not.

Author(s)

Dirk Eddelbuettel

Examples

inGit()

dang documentation built on May 29, 2024, 2:53 a.m.