Description Usage Arguments Details Value Examples
Use this to convert a path into a git_repository
object,
which is how the git2r
package handles Git repositories. This
function is a slightly more flexible version of
git2r::repository()
.
1 | as.git_repository(x, ...)
|
x |
path that is or is in a Git repository; defaults to working directory |
... |
additional arguments, such as |
githug
uses git2r
, under the hood, to perform local Git
operations. While githug
always identifies the repository via its
path, git2r
handles repositories as objects of class
git_repository
. If you want to do a Git operation that
isn't exposed via githug
, this function helps you specify the
repository git2r
-style.
An S4 git_repository
object
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | repo <- git_init(tempfile("git-repository-example-"))
## you can specify the path explicitly
as.git_repository(repo)
## switch working directory to the repo
owd <- setwd(repo)
## as.git_repository() with no args consults working directory
as.git_repository()
dir.create("subdir")
## as.git_repository() walks up parents, looking for a repo
as.git_repository("subdir")
setwd("subdir")
as.git_repository()
## unless you put a ceiling on the walk
## Not run:
as.git_repository("repo-path/subdir", ceiling = 0)
## End(Not run)
setwd(owd)
## Not run:
## here's a rather exotic Git operation that githug is unlikely to expose:
## odb_blobs() lists "all blobs reachable from the commits in the object database"
## pre-process the repo with as_git_repository() to prepare for git2r
git2r::odb_blobs(as.git_repository("path_to_a_git_repo"))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.