mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-14 21:09:50 +02:00
documentation added, Tests Fixed
This commit is contained in:
@@ -366,41 +366,49 @@ A few important rules to note here are:
|
|||||||
1. You need to provide the `id` for an existing commit to be cherry-picked. If given commit id does not exist it will result in an error. For this, make use of the `commit id:$value` format of declaring commits. See the examples from above.
|
1. You need to provide the `id` for an existing commit to be cherry-picked. If given commit id does not exist it will result in an error. For this, make use of the `commit id:$value` format of declaring commits. See the examples from above.
|
||||||
2. The given commit must not exist on the current branch. The cherry-picked commit must always be a different branch than the current branch.
|
2. The given commit must not exist on the current branch. The cherry-picked commit must always be a different branch than the current branch.
|
||||||
3. Current branch must have at least one commit, before you can cherry-pick, otherwise it will cause an error is throw.
|
3. Current branch must have at least one commit, before you can cherry-pick, otherwise it will cause an error is throw.
|
||||||
|
4. When cherry-picking a merge commit, providing a parent commit ID is mandatory. If the parent attribute is omitted or an invalid parent commit ID is provided, an error will be thrown.
|
||||||
|
5. The specified parent commit must be an immediate parent of the merge commit being cherry-picked.
|
||||||
|
|
||||||
Let see an example:
|
Let see an example:
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
gitGraph
|
gitGraph
|
||||||
commit id: "ZERO"
|
commit id: "ZERO"
|
||||||
branch develop
|
branch develop
|
||||||
commit id:"A"
|
branch release
|
||||||
checkout main
|
commit id:"A"
|
||||||
commit id:"ONE"
|
checkout main
|
||||||
checkout develop
|
commit id:"ONE"
|
||||||
commit id:"B"
|
checkout develop
|
||||||
checkout main
|
commit id:"B"
|
||||||
commit id:"TWO"
|
checkout main
|
||||||
cherry-pick id:"A"
|
merge develop id:"MERGE"
|
||||||
commit id:"THREE"
|
commit id:"TWO"
|
||||||
checkout develop
|
checkout release
|
||||||
commit id:"C"
|
cherry-pick id:"MERGE" parent:"B"
|
||||||
|
commit id:"THREE"
|
||||||
|
checkout develop
|
||||||
|
commit id:"C"
|
||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
gitGraph
|
gitGraph
|
||||||
commit id: "ZERO"
|
commit id: "ZERO"
|
||||||
branch develop
|
branch develop
|
||||||
commit id:"A"
|
branch release
|
||||||
checkout main
|
commit id:"A"
|
||||||
commit id:"ONE"
|
checkout main
|
||||||
checkout develop
|
commit id:"ONE"
|
||||||
commit id:"B"
|
checkout develop
|
||||||
checkout main
|
commit id:"B"
|
||||||
commit id:"TWO"
|
checkout main
|
||||||
cherry-pick id:"A"
|
merge develop id:"MERGE"
|
||||||
commit id:"THREE"
|
commit id:"TWO"
|
||||||
checkout develop
|
checkout release
|
||||||
commit id:"C"
|
cherry-pick id:"MERGE" parent:"B"
|
||||||
|
commit id:"THREE"
|
||||||
|
checkout develop
|
||||||
|
commit id:"C"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Gitgraph specific configuration options
|
## Gitgraph specific configuration options
|
||||||
|
@@ -345,8 +345,8 @@ export const cherryPick = function (sourceId, targetId, tag, parentCommitId) {
|
|||||||
type: commitType.CHERRY_PICK,
|
type: commitType.CHERRY_PICK,
|
||||||
tag:
|
tag:
|
||||||
tag ??
|
tag ??
|
||||||
`cherry-pick: ${sourceCommit.id}${
|
`cherry-pick:${sourceCommit.id}${
|
||||||
sourceCommit.type === commitType.MERGE ? ` | parent: ${parentCommitId}` : ''
|
sourceCommit.type === commitType.MERGE ? `|parent:${parentCommitId}` : ''
|
||||||
}`,
|
}`,
|
||||||
};
|
};
|
||||||
head = commit;
|
head = commit;
|
||||||
|
@@ -690,7 +690,7 @@ describe('when parsing a gitGraph', function () {
|
|||||||
parser.parse(str);
|
parser.parse(str);
|
||||||
const commits = parser.yy.getCommits();
|
const commits = parser.yy.getCommits();
|
||||||
const cherryPickCommitID = Object.keys(commits)[4];
|
const cherryPickCommitID = Object.keys(commits)[4];
|
||||||
expect(commits[cherryPickCommitID].tag).toBe('cherry-pick: M | parent: B');
|
expect(commits[cherryPickCommitID].tag).toBe('cherry-pick:M|parent:B');
|
||||||
expect(commits[cherryPickCommitID].branch).toBe('release');
|
expect(commits[cherryPickCommitID].branch).toBe('release');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -244,24 +244,29 @@ A few important rules to note here are:
|
|||||||
1. You need to provide the `id` for an existing commit to be cherry-picked. If given commit id does not exist it will result in an error. For this, make use of the `commit id:$value` format of declaring commits. See the examples from above.
|
1. You need to provide the `id` for an existing commit to be cherry-picked. If given commit id does not exist it will result in an error. For this, make use of the `commit id:$value` format of declaring commits. See the examples from above.
|
||||||
2. The given commit must not exist on the current branch. The cherry-picked commit must always be a different branch than the current branch.
|
2. The given commit must not exist on the current branch. The cherry-picked commit must always be a different branch than the current branch.
|
||||||
3. Current branch must have at least one commit, before you can cherry-pick, otherwise it will cause an error is throw.
|
3. Current branch must have at least one commit, before you can cherry-pick, otherwise it will cause an error is throw.
|
||||||
|
4. When cherry-picking a merge commit, providing a parent commit ID is mandatory. If the parent attribute is omitted or an invalid parent commit ID is provided, an error will be thrown.
|
||||||
|
5. The specified parent commit must be an immediate parent of the merge commit being cherry-picked.
|
||||||
|
|
||||||
Let see an example:
|
Let see an example:
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
gitGraph
|
gitGraph
|
||||||
commit id: "ZERO"
|
commit id: "ZERO"
|
||||||
branch develop
|
branch develop
|
||||||
commit id:"A"
|
branch release
|
||||||
checkout main
|
commit id:"A"
|
||||||
commit id:"ONE"
|
checkout main
|
||||||
checkout develop
|
commit id:"ONE"
|
||||||
commit id:"B"
|
checkout develop
|
||||||
checkout main
|
commit id:"B"
|
||||||
commit id:"TWO"
|
checkout main
|
||||||
cherry-pick id:"A"
|
merge develop id:"MERGE"
|
||||||
commit id:"THREE"
|
commit id:"TWO"
|
||||||
checkout develop
|
checkout release
|
||||||
commit id:"C"
|
cherry-pick id:"MERGE" parent:"B"
|
||||||
|
commit id:"THREE"
|
||||||
|
checkout develop
|
||||||
|
commit id:"C"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Gitgraph specific configuration options
|
## Gitgraph specific configuration options
|
||||||
|
Reference in New Issue
Block a user