githug (version 0.0.0.9000)

git_history: Get the commit history

Description

Get an overview of the last n commits. Convenience wrapper around git2r::commits(). The print method shows truncated versions of selected variables, e.g., the commit message, time, and SHA, but rest assured the full information is present in the returned object.

Usage

git_history(repo = ".", ...)

Arguments

repo
Path to a Git repo. If unspecified, current working directory is checked to see if it is or is inside a Git repo.
...
Optional parameters passed through to git2r::commits(). Can include:
  • n Max number of commits.
  • topological Logical, requests topological sort, i.e. parent before child, defaults to TRUE. Can be combined with time.
  • time Logical, requests chronological sort, defaults to TRUE. Can be combined with topological.
  • reverse Logical, reverses the order, defaults to FALSE.

Value

A data frame with S3 class git_history, solely for printing purposes. Variables: the SHA, commit message, when the commit happened, author, and email.

Examples

Run this code
repo <- git_init(tempfile("git-history-"))
owd <- setwd(repo)
line1 <- "Thelma: You're a real live outlaw, aren't ya?"
line2 <- paste("J.D.: Well I may be an outlaw, darlin', but you're the one",
               "stealing my heart.")
write(line1, "tl.txt")
git_commit("tl.txt", message = "first commit")
write(line2, "tl.txt", append = TRUE)
git_commit("tl.txt", message = "second commit")
git_history()
setwd(owd)

Run the code above in your browser using DataLab