Skip to content

Commit

Permalink
fix: Check if parentCommit is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
sidharthv96 committed Dec 4, 2023
1 parent 31a1de1 commit d22ee8d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/mermaid/src/diagrams/git/gitGraphAst.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
);
Expand Down

0 comments on commit d22ee8d

Please sign in to comment.