From d22ee8d1d55eb278d61272d69c7a467ed080b1c9 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Mon, 4 Dec 2023 11:13:52 +0530 Subject: [PATCH] fix: Check if parentCommit is provided --- packages/mermaid/src/diagrams/git/gitGraphAst.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphAst.js b/packages/mermaid/src/diagrams/git/gitGraphAst.js index 3d34283b38..bd90c87173 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphAst.js +++ b/packages/mermaid/src/diagrams/git/gitGraphAst.js @@ -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.' );