Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: commits() for other objects #234

Open
krlmlr opened this issue May 10, 2016 · 1 comment
Open

FR: commits() for other objects #234

krlmlr opened this issue May 10, 2016 · 1 comment

Comments

@krlmlr
Copy link
Contributor

krlmlr commented May 10, 2016

  • commit
  • branch
  • repo + SHA1
  • ...
@stewid
Copy link
Member

stewid commented May 18, 2016

Hi @krlmlr

I have started to work on this and added commits methods with signature git_commit, git_branch and git_tag in the fr_commits branch. Is this the functionality you meant?

library(git2r)

## Create a directory in tempdir
path <- tempfile(pattern="git2r-")
dir.create(path)

## Initialize a repository
repo <- init(path)
config(repo, user.name="Alice", user.email="[email protected]")

## Create a file and commit
writeLines("Hello world!", file.path(path, "test.txt"))
add(repo, "test.txt")
commit_1 <- commit(repo, "First commit message")

## Update the file and commit
writeLines(c("Hello world!", "Hello world!"), file.path(path, "test.txt"))
add(repo, "test.txt")
commit_2 <- commit(repo, "Second commit message")

## Add a tag
tag_1 <- tag(repo, "Tagname", "Tag message")

## List commits
commits(repo)
#> [[1]]
#> [f520221] 2016-05-18: Second commit message
#> 
#> [[2]]
#> [25d02cb] 2016-05-18: First commit message
commits(commit_1)
#> [[1]]
#> [f520221] 2016-05-18: Second commit message
#> 
#> [[2]]
#> [25d02cb] 2016-05-18: First commit message
commits(commit_2)
#> [[1]]
#> [f520221] 2016-05-18: Second commit message
#> 
#> [[2]]
#> [25d02cb] 2016-05-18: First commit message
commits(tag_1)
#> [[1]]
#> [f520221] 2016-05-18: Second commit message
#> 
#> [[2]]
#> [25d02cb] 2016-05-18: First commit message
commits(branches(repo)$master)
#> [[1]]
#> [f520221] 2016-05-18: Second commit message
#> 
#> [[2]]
#> [25d02cb] 2016-05-18: First commit message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants