fix: Check if parentCommit is provided

This commit is contained in:
Sidharth Vinod
2023-12-04 11:13:52 +05:30
parent 31a1de1566
commit d22ee8d1d5

View File

@@ -277,7 +277,10 @@ export const cherryPick = function (sourceId, targetId, tag, parentCommitId) {
}
let sourceCommit = commits[sourceId];
let sourceCommitBranch = sourceCommit.branch;
if (!(Array.isArray(sourceCommit.parents) && sourceCommit.parents.includes(parentCommitId))) {
if (
parentCommitId &&
!(Array.isArray(sourceCommit.parents) && sourceCommit.parents.includes(parentCommitId))
) {
let error = new Error(
'Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit.'
);