This repository was archived by the owner on Dec 2, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Dec 2, 2026. It is now read-only.
(Bug) Revert.revert requires a RevertOptions parameter #1403
Copy link
Copy link
Closed
Description
Revert.revert requires a Revert Options parameter or a null to be passed into the method unlike other methods such as Merge.merge
Lines 28 to 39 in 6ff67a8
| /** | |
| * Merge a commit into HEAD and writes the results to the working directory. | |
| * | |
| * @param {Repository} repo Repository that contains the given commits | |
| * @param {AnnotatedCommit} theirHead The annotated commit to merge into HEAD | |
| * @param {MergeOptions} [mergeOpts] The merge tree options (null for default) | |
| * @param {CheckoutOptions} [checkoutOpts] The checkout options | |
| * (null for default) | |
| */ | |
| Merge.merge = function(repo, theirHead, mergeOpts, checkoutOpts) { | |
| mergeOpts = normalizeOptions(mergeOpts || {}, NodeGit.MergeOptions); | |
| checkoutOpts = normalizeOptions(checkoutOpts || {}, NodeGit.CheckoutOptions); |
and Revert.commit
Lines 16 to 29 in 6ff67a8
| * @param {MergeOptions} merge_options the merge options (or null for defaults) | |
| * | |
| * @return {Index} the index result | |
| */ | |
| Revert.commit = function( | |
| repo, | |
| revert_commit, | |
| our_commit, | |
| mainline, | |
| merge_options, | |
| callback | |
| ) | |
| { | |
| merge_options = normalizeOptions(merge_options, NodeGit.MergeOptions); |
When a RevertOptions parameter is not passed into Revert.revert this error is thrown
(node:46081) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Callback is required and must be a Function. when talking with @rcjsuen in slack he noticed that the error was misleading and originated from the c++ layer.
Here is the code that threw this error
/**
* @description reverts the git branch to the requested commit
* @param {String} hash represents the hash of the commit
* @async
*/
async function revert(hash) {
return new Promise(async function handlePromise(resolve, reject) {
try {
let repo = await openRepository(sitePath);
logger.info('Setting new head...');
let newHead = await repo.getCommit(hash);
logger.info('Reverting...');
await Git.Revert.revert(
repo,
newHead,
);
return resolve();
} catch(err) {
logger.error(`${err}`);
return reject(err);
}
});
}
Metadata
Metadata
Assignees
Labels
No labels
Activity
[-]Revert.revert requires a RevertOptions parameter[/-][+](Bug) Revert.revert requires a RevertOptions parameter[/+]ethomson commentedon Nov 26, 2017
That error's not coming from libgit2, we don't have any notion of promises. 😀
rcjsuen commentedon Nov 26, 2017
@ethomson Yeah, it's coming from NodeGit's generated C++ layer. Don't worry, it's not an issue with libgit2. :)
ethomson commentedon Nov 27, 2017
Thanks @rcjsuen for the clarification. 😁