Generate default options for Revert.revert to prevent an exception#1404
Merged
Conversation
implausible
requested changes
Nov 27, 2017
| * (or null for defaults) | ||
| */ | ||
| Revert.revert = function(repo, commit, revertOpts) { | ||
| revertOpts = normalizeOptions(revertOpts || {}, NodeGit.RevertOptions); |
Member
There was a problem hiding this comment.
I believe revert options also has checkout and merge options nested in it. You may need to pull those out and normalize them. Checkout the normalizeFetchOptions.js file to see how we've normalized nested options structures before.
Due to the way the C++ binding layer gets the promise callback passed to it, if there are no options specified in Revert.revert, the promise callback ends up becoming the third parameter to the function and the expected fourth parameter will not be satisfied which will lead to an exception. We should generate a default options for Revert.revert if nothing is provided by the callee to make the API easier and simpler to use. Signed-off-by: Remy Suen <[email protected]>
f435236 to
e8f8141
Compare
Member
Author
|
Thank you for the review, @implausible. Could you take a look at the new changes that I've pushed? Thanks! :) |
Member
|
That's awesome, thanks @rcjsuen. |
implausible
approved these changes
Nov 28, 2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If no options are specified for
Revert.revert, the promise callback becomes the third parameter for the generated C++ revert.cc file and the (expected) fourth parameter as the promise callback will be unsatisfied which will lead to an exception. To fix this, we should generate a default options for the function instead of the callee doesn't provide one.This fixes #1403.