mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-18 23:09:49 +02:00
Condition of Parent Id Without Merge Commit Added
This commit is contained in:
@@ -277,19 +277,17 @@ export const cherryPick = function (sourceId, targetId, tag, parentCommitId) {
|
|||||||
}
|
}
|
||||||
let sourceCommit = commits[sourceId];
|
let sourceCommit = commits[sourceId];
|
||||||
let sourceCommitBranch = sourceCommit.branch;
|
let sourceCommitBranch = sourceCommit.branch;
|
||||||
if (sourceCommit.type === commitType.MERGE) {
|
|
||||||
if (!parentCommitId) {
|
|
||||||
let error = new Error(
|
|
||||||
'Incorrect usage of cherry-pick: If the source commit is a merge commit, an immediate parent commit must be specified.'
|
|
||||||
);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
if (!(Array.isArray(sourceCommit.parents) && sourceCommit.parents.includes(parentCommitId))) {
|
if (!(Array.isArray(sourceCommit.parents) && sourceCommit.parents.includes(parentCommitId))) {
|
||||||
let error = new Error(
|
let error = new Error(
|
||||||
'Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit.'
|
'Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit.'
|
||||||
);
|
);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
if (sourceCommit.type === commitType.MERGE && !parentCommitId) {
|
||||||
|
let error = new Error(
|
||||||
|
'Incorrect usage of cherry-pick: If the source commit is a merge commit, an immediate parent commit must be specified.'
|
||||||
|
);
|
||||||
|
throw error;
|
||||||
}
|
}
|
||||||
if (!targetId || commits[targetId] === undefined) {
|
if (!targetId || commits[targetId] === undefined) {
|
||||||
// cherry-pick source commit to current branch
|
// cherry-pick source commit to current branch
|
||||||
|
Reference in New Issue
Block a user