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

Add bindings for push_negotiation callback #926

Merged
merged 2 commits into from
Apr 2, 2023
Merged

Add bindings for push_negotiation callback #926

merged 2 commits into from
Apr 2, 2023

Conversation

karin0
Copy link
Contributor

@karin0 karin0 commented Feb 1, 2023

This fixes #733 .

This PR adds RemoteCallbacks::push_negotiation, PushNegotiation and PushUpdate to expose the push_negotiation callback. A test is added at the end of src/remote.rs.

Copy link

@samueltardieu samueltardieu left a 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.

Copy link
Contributor

@ehuss ehuss left a 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.

/// commands to the destination.
///
/// The return value indicates whether the push should continue.
pub type PushNegotiation<'a> = dyn FnMut(&[PushUpdate<'_>]) -> bool + 'a;
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

@ehuss ehuss left a 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!

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

Successfully merging this pull request may close these issues.

Add support for push negotiation callback
3 participants