You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was working with a student this morning to track down an error in calling git2r::commits(repo), and the issue turned out to be that she had not yet made a first commit (I'm pretty sure that this was the issue, but not 100%).
A small helpful tweak for beginners would be to edit the error message for this specific case. So something informing the user that no commits had been made yet, rather than Error in UseMethod("sha", object): no applicable method for 'sha' applied to an object of class NULL.
Thanks!
Will
The text was updated successfully, but these errors were encountered:
Thanks for the suggestion. I've not been able to reproduce the error using the following code, so I'm not sure what went wrong in that specific case.
library(git2r)
path <- tempfile(pattern="git2r-")
dir.create(path)
## Try to list the commits in a non-repository.
## Raises "Error in repository(repo) : The 'path' is not in a git repository"
commits(path)
## Try to list the commits in an empty repository.
## Returns an empty list()
repo <- init(path)
commits(repo)
## Create a file and add it to the repository. Then try to list the commits.
## Returns an empty list()
lines <- "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do"
writeLines(lines, file.path(path, "example.txt"))
add(repo, "example.txt")
commits(repo)
## Add one commit and then list the commits.
## Returns the first commit.
commit(repo, "First commit message")
commits(repo)
Hi
I was working with a student this morning to track down an error in calling
git2r::commits(repo)
, and the issue turned out to be that she had not yet made a first commit (I'm pretty sure that this was the issue, but not 100%).A small helpful tweak for beginners would be to edit the error message for this specific case. So something informing the user that no commits had been made yet, rather than
Error in UseMethod("sha", object): no applicable method for 'sha' applied to an object of class NULL
.Thanks!
Will
The text was updated successfully, but these errors were encountered: