dang (version 0.0.16)

getGitRoot: 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())

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.

Arguments

cwd

The start directory, default to the current working directory

Author

Dirk Eddelbuettel

Examples

Run this code
inGit()

Run the code above in your browser using DataLab