Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

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

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

'Dang' Associated New Goodies

v0.0.13
GPL (>= 2)
Authors
Dirk Eddelbuettel with contributions by Brodie Gaslam, Kevin Denny, Kabira Namit, Colin Gillespie, R Core, Josh Ulrich, and others.
Initial release
2021-02-17

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.