Skip to content

Adding Pre-Push Callback Support #1061

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

Merged
merged 1 commit into from
Jun 10, 2015
Merged

Adding Pre-Push Callback Support #1061

merged 1 commit into from
Jun 10, 2015

Conversation

whoisj
Copy link

@whoisj whoisj commented May 29, 2015

added PushUpdate class, updated GitPushUpdate struct

completed plumbing from libgit2 => API layer

added a positive test, failed to get a negative test to work correctly

@whoisj
Copy link
Author

whoisj commented May 29, 2015

Currently return anything except 0 from the hook will cause an exception to be thrown in the managed layer. I'm not sure this is what we want to be seeing. Perhaps it is. Having a hook block a push for any reason might not be considered exceptional. I'm looking for feedback on this.

Once we have the answer to the above, I'll complete the negative test case to insure than returning a failing value blocks the upload portion of the push.

/// Called once between the negotiation step and the upload. It provides
/// information about what updates will be performed.
/// </summary>
public PrePushHookHandler OnNegotationCompletedBeforePush { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Negotiation is misspelled 😄

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a senior member of the American Bad Spellers Society Id like to thank you for recognition of my (in)abilities. 😆

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@whoisj FWIW, most of the spell checking tools delegate the hard work to @jamill

@jamill
Copy link
Member

jamill commented Jun 1, 2015

Having a hook block a push for any reason might not be considered exceptional. I'm looking for feedback on this.

I think it is reasonable for an exception generated in the push handler to block the push. If someone is relying on the hook to approve changes, then I would like for an error to block the push.

@jamill
Copy link
Member

jamill commented Jun 1, 2015

@whoisj Thanks for the PR 🎆 ! I think this will be nice addition. I had some feedback and weighed in on your question.

@whoisj
Copy link
Author

whoisj commented Jun 1, 2015

I believe the PR is all fixed up based on the feedback so far.

I found a handy Assert.Throws<UserCancelledException> utility function that cleared the way for a successful negative unit test.

@whoisj whoisj closed this Jun 1, 2015
@whoisj whoisj reopened this Jun 1, 2015
@whoisj
Copy link
Author

whoisj commented Jun 1, 2015

darn github close and comment button. It's larger than the comment button and there's no confirmation dialog. I think I've close and reopened every PR I've started accidentally at this point 😖

@whoisj whoisj changed the title Adding Support for Pre-Push Hooks Adding Pre-Push Callback Support Jun 1, 2015
@whoisj
Copy link
Author

whoisj commented Jun 3, 2015

I believe everything is hunky-dory

/CC @nulltoken @jamill

PackBuilderProgressHandler packBuilderCb = (x, y, z) => { packBuilderCalled = true; return true; };
PrePushHandler prePushHook = (IEnumerable<PushUpdate> updates) =>
{
Assert.True(updates.Count() == 1, "Expected 1 update, recieved " + updates.Count());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

received?

@whoisj
Copy link
Author

whoisj commented Jun 5, 2015

@nulltoken spelling errors corrected in the test code 😜

@nulltoken
Copy link
Member

🆒 Before we merge this in, could you please sprinkle a bit of your squashing magic on this PR?

Added `PushUpdate` class, updated `GitPushUpdate` struct

Completed plumbing from libgit2 => API layer

Added both positive and negative tests to the `PushFixture`
@whoisj
Copy link
Author

whoisj commented Jun 10, 2015

🆒 Before we merge this in, could you please sprinkle a bit of your squashing magic on this PR?

Done sir, all squashed up. 😇

nulltoken added a commit that referenced this pull request Jun 10, 2015
@nulltoken nulltoken merged commit a4f7831 into libgit2:vNext Jun 10, 2015
@nulltoken
Copy link
Member

💥 ‼️

@nulltoken nulltoken added this to the v0.22 milestone Jun 10, 2015
@whoisj whoisj deleted the pre-push-hook-support branch June 10, 2015 17:18
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.

5 participants