-
Notifications
You must be signed in to change notification settings - Fork 62
ls_remote function #172
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
ls_remote function #172
Conversation
Analogous to git ls-remote, returns all references from a remote repository.
@jimhester thanks a lot! I suggest we change the name to I take a closer look at the code later today. |
👍 on |
src/git2r_remote.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
git2r_repository_open
can return NULL
and must be checked before usage, see https://github.com/ropensci/git2r/blob/master/src/git2r_remote.c#L54
if (!repository)
git2r_error(git2r_err_invalid_repository, __func__, NULL);
- Rename to remote_ls - Check result of git2r_repository_open - Use err for error codes - Explicitly assign to err so it can be used for printing error messages - Allocate, assign and set names in one statement - Move statements after all variable definitions - Add optional credentials parameter - Fix documentation typo
Ok 4a3187d should address all of your suggestions. Thank you for the review! Let me know if you see anything else that needs to be changed. |
cd77539 is passing |
Thank you, I look at the code today. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to cleanup the temporary repository? One way could be to change the default repo
argument to NULL
and then something like this in the method:
path <- NULL
if (is.null(repo)) {
path <- tempdir()
repo <- git2r::init(path)
}
.Call(git2r_remote_ls, name, repo, credentials)
if (!is.null(path))
unlink(path, recursive=TRUE)
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The initial repository does not have a large size footprint and the tempdir will be removed when the R session ends, which is why I didn't clean it up explicitly. I added cleanup with jimhester@5b2067d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the usage of on.exit
for the cleanup and also realize that my suggestion would actually fail to cleanup if .Call(...)
fails.
Thanks for this PR 👍 |
Great thanks, and thank you for the code review! |
@stewid any way to do what |
@sckott no it only works with the development version. When do plan to push |
If all you need to do is verify a remote is valid you could just try
|
I already pushed it to CRAN - I did as @jimhester suggested, used |
Great |
Analogous to git ls-remote, returns all references from a remote
repository.
Fixes #130
I added documentation, tests and a note to NEWS. The libgit2 functions require a repository object to work, but the only information you really need for this is the remote URL. The interface allows you to pass a repository object if you want, otherwise it simply creates a temporary object in
tempdir()
and uses that.