githug (version 0.0.0.9000)

as_git_repository: Open a Git repository, the git2r way

Description

githug uses the git2r package, under the hood, to perform local Git operations. git2r handles Git repos as objects of class git_repository. Use this function to convert a path (or other way of referring to a Git repo) to the right sort of input. You might need this for more exotic Git operations, i.e. to call git2r functions that aren't exposed via githug.

Usage

as_git_repository(x = ".")

Arguments

x
Git repository specified as a path. Or as an object of class rpath (S3 class used only internally in githug) or of class git_repository (from the git2r package).

Value

An S4 git_repository object

Examples

Run this code
repo <- git_init(tempfile("githug-to-git2r-example-"))
owd <- setwd(repo)
git_config(user.name = "jd", user.email = "jd@example.org")
writeLines(paste("Well, I've always believed that if done properly, armed",
                 "robbery doesn't have to be an unpleasant experience."),
           "jd.txt")
git_add("jd.txt")
git_commit("jd is a smooth talker")

## 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())
setwd(owd)

Run the code above in your browser using DataLab