in_repository: Determine if a directory is in a git repository

Description Usage Arguments Value Examples

View source: R/repository.R

Description

The lookup start from path and walk across parent directories if nothing has been found.

Usage

1
in_repository(path = ".")

Arguments

path

The path to the directory.

Value

TRUE if directory is in a git repository else FALSE

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## Not run: 
## Initialize a temporary repository
path <- tempfile(pattern="git2r-")
dir.create(path)
repo <- init(path)

## Create a user
config(repo, user.name = "Alice", user.email = "alice@example.org")

## Check if path is in a git repository
in_repository(path)

## Check if working directory is in a git repository
setwd(path)
in_repository()

## End(Not run)

Example output

[1] TRUE
[1] TRUE

git2r documentation built on Nov. 22, 2021, 9:08 a.m.

Related to in_repository in git2r...