git_history: Get the commit history

Description Usage Arguments Value Examples

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

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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)

jennybc/githug documentation built on May 19, 2019, 5:05 a.m.