R: Determine if the repository was a shallow clone
is_shallow
R Documentation
Determine if the repository was a shallow clone
Description
Determine if the repository was a shallow clone
Usage
is_shallow(repo)
## S4 method for signature 'missing'
is_shallow()
## S4 method for signature 'git_repository'
is_shallow(repo)
Arguments
repo
The repository objectgit_repository. If the repo argument
is missing, the repository is searched for with
discover_repository in the current working
directory.
Value
TRUE if shallow clone, else FALSE
Examples
## Not run:
## Initialize repository
path_repo_1 <- tempfile(pattern="git2r-")
path_repo_2 <- tempfile(pattern="git2r-")
dir.create(path_repo_1)
dir.create(path_repo_2)
repo_1 <- init(path_repo_1)
## Config user and commit a file
config(repo_1, user.name="Alice", user.email="alice@example.org")
## Write to a file and commit
writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do",
file.path(path_repo_1, "example.txt"))
add(repo_1, "example.txt")
commit(repo_1, "First commit message")
## Change file and commit
writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do",
"eiusmod tempor incididunt ut labore et dolore magna aliqua."),
file.path(path_repo_1, "example.txt"))
add(repo_1, "example.txt")
commit(repo_1, "Second commit message")
## Change file again and commit.
writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do",
"eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad",
"minim veniam, quis nostrud exercitation ullamco laboris nisi ut"),
file.path(path_repo_1, "example.txt"))
add(repo_1, "example.txt")
commit(repo_1, "Third commit message")
## Clone to second repository
repo_2 <- clone(path_repo_1, path_repo_2)
## Check if it's a shallow clone
is_shallow(repo_2)
## End(Not run)