githug (version 0.0.0.9000)

as.git_commit: Address a commit, the git2r way

Description

Use this to convert a revision string into an object of class git_commit, which is how the git2r package handles Git commits.

Usage

as.git_commit(x, repo = ".", ...)

Arguments

x
Target commit, as a revision string, e.g. HEAD^, branchname, SHA-1 or a leading substring thereof.
repo
Path to a Git repo. If unspecified, current working directory is checked to see if it is or is inside a Git repo.
...
additional arguments (none currently in use)

Value

An S4 git_commit object

Details

githug uses git2r, under the hood, to perform local Git operations. While githug always identifies a commit via its SHA or a revision string, git2r handles repositories as objects of class git_commit. If you want to do a Git operation that isn't exposed via githug, this function helps you specify the commit git2r-style.

Examples

Run this code
repo <- git_init(tempfile("githug-"))
owd <- setwd(repo)
write("Are these girls real smart or real real lucky?", "max.txt")
write("You get what you settle for.", "louise.txt")
git_commit(all = TRUE,
           message = "Brains'll only get you so far and luck always runs out.")
write("If done properly armed robbery doesn't have to be a totally unpleasant experience.",
      "jd.txt")
git_commit("jd.txt", message = "J.D. is charming")

## refer to these commits
as.git_commit("HEAD")
as.git_commit("HEAD^")
as.git_commit("master~1")

setwd(owd)

Run the code above in your browser using DataCamp Workspace