-
Notifications
You must be signed in to change notification settings - Fork 405
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
Add bindings for push_negotiation callback #926
Conversation
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 think this is a great addition to git2-rs, I hope it can be merged soon.
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.
Thanks, sorry for the long delay.
src/remote_callbacks.rs
Outdated
/// commands to the destination. | ||
/// | ||
/// The return value indicates whether the push should continue. | ||
pub type PushNegotiation<'a> = dyn FnMut(&[PushUpdate<'_>]) -> bool + 'a; |
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.
Is there any particular reason this returns a bool? I was thinking it could return a Result<(), Error>
, similar to other callbacks so that it is clear that it is triggering an error. A bool seems more innocuous, and not a typical way to do error handling in Rust.
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.
Thanks for the review! I've made the changes. I might have been emulating sideband_progress
, where the callback also returns a bool
to decide whether to cancel the operation, but using a Result
is indeed more idiomatic here.
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.
Thanks!
Yea, after looking more closely I realized that the callbacks aren't very consistent if they use bools or Results.
Also, thanks for adding the detailed test!
This fixes #733 .
This PR adds
RemoteCallbacks::push_negotiation
,PushNegotiation
andPushUpdate
to expose thepush_negotiation
callback. A test is added at the end ofsrc/remote.rs
.