Revert.revert requires a Revert Options parameter or a null to be passed into the method unlike other methods such as Merge.merge
|
/** |
|
* 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
|
* @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);
}
});
}
Revert.revert requires a Revert Options parameter or a null to be passed into the method unlike other methods such as Merge.merge
nodegit/lib/merge.js
Lines 28 to 39 in 6ff67a8
and Revert.commit
nodegit/lib/revert.js
Lines 16 to 29 in 6ff67a8
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