Are there methods for these already?I'm not having much luck finding them. I'd like to have a colophon with git info like so, but feel a bit uncomfortable using @:
```{r, echo=FALSE}
library("git2r")
# create repository
path <- tempfile(pattern="test_repo_")
dir.create(path)
repo <- init(path)
# configure user
config(repo, user.name="Alice", user.email="alice@example.org")
## Write to a file and commit
writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do",
file.path(path, "example.txt"))
add(repo, "example.txt")
commit(repo, "First commit message")
last_commit<- commits(repo)[[1]]The current git commit of this file is r last_commit@sha, which is on the r branches(repo)[[1]]@name branch and was made by r last_commit@committer@name on r when(last_commit). The current commit message is "r last_commit@summary".
Which renders nicely as:
The current git commit of this file is 0d0a2e8b40dbcc2b4ad5125fa6e1f08ec5244160, which is on the master branch and was made by Alice on 2015-05-07 23:17:20. The current commit message is “First commit message”.
Are there methods for these already?I'm not having much luck finding them. I'd like to have a colophon with git info like so, but feel a bit uncomfortable using
@:The current git commit of this file is
r last_commit@sha, which is on ther branches(repo)[[1]]@namebranch and was made byr last_commit@committer@nameonr when(last_commit). The current commit message is "r last_commit@summary".Which renders nicely as:
The current git commit of this file is 0d0a2e8b40dbcc2b4ad5125fa6e1f08ec5244160, which is on the master branch and was made by Alice on 2015-05-07 23:17:20. The current commit message is “First commit message”.