From d60ce53e05a8ccdf5d70cce7813226cab59d5f8f Mon Sep 17 00:00:00 2001 From: ashishj Date: Tue, 13 Sep 2022 18:23:24 +0200 Subject: [PATCH 01/13] #3409 Fixed the truncated tags issue --- cypress/platform/gitgraph.html | 25 +++++++++++++++++++++++++ src/diagrams/git/gitGraphRenderer.js | 17 +++-------------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/cypress/platform/gitgraph.html b/cypress/platform/gitgraph.html index da81427f8..d8d16f6c9 100644 --- a/cypress/platform/gitgraph.html +++ b/cypress/platform/gitgraph.html @@ -30,7 +30,31 @@

info below

+
+  %%{init: { "logLevel": "debug", "theme": "default" , "gitGraph" : {"showBranches":"false","rotateCommitLabel":"true"},"themeVariables": {
+              "gitBranchLabel0": "#ff0000",
+              "gitBranchLabel1": "#00ff00",
+              "gitBranchLabel2": "#0000ff",
+              "git0": "#550055"
+       } } }%%
+    gitGraph
+      commit
+       branch develop
+       commit
+       commit
+       branch release/1.0.0
+       checkout release/1.0.0
+       commit tag:"1.0.0-beta1"
+       checkout develop
+       commit
+       commit
+       commit
+       commit
+       checkout release/1.0.0
+       merge develop tag: "1.0.0-beta2"
+    
+
     %%{init: { "logLevel": "debug", "theme": "default" , "gitGraph" : {"showBranches":"false"},"themeVariables": {
               "gitBranchLabel0": "#ff0000",
               "gitBranchLabel1": "#00ff00",
@@ -131,6 +155,7 @@
         // arrowMarkerAbsolute: true,
         // themeCSS: '.edgePath .path {stroke: red;} .arrowheadPath {fill: red;}',
         logLevel: 1,
+        gitGraph: {rotateCommitLabel: false},
         flowchart: { curve: 'linear', htmlLabels: true },
         // gantt: { axisFormat: '%m/%d/%Y' },
         sequence: { actorMargin: 50, showSequenceNumbers: true },
diff --git a/src/diagrams/git/gitGraphRenderer.js b/src/diagrams/git/gitGraphRenderer.js
index 5a9036b88..79339d727 100644
--- a/src/diagrams/git/gitGraphRenderer.js
+++ b/src/diagrams/git/gitGraphRenderer.js
@@ -1,7 +1,6 @@
 import { select } from 'd3';
-import { configureSvgSize } from '../../setupGraphViewbox';
+import { getConfig,setupGraphViewbox } from '../../diagram-api/diagramAPI';
 import { log } from '../../logger';
-import { getConfig } from '../../config';
 import addSVGAccessibilityFields from '../../accessibility';
 
 let allCommitsDict = {};
@@ -542,18 +541,8 @@ export const draw = function (txt, id, ver, diagObj) {
   drawArrows(diagram, allCommitsDict);
   drawCommits(diagram, allCommitsDict, true);
 
-  const padding = gitGraphConfig.diagramPadding;
-  const svgBounds = diagram.node().getBBox();
-  const width = svgBounds.width + padding * 2;
-  const height = svgBounds.height + padding * 2;
-
-  configureSvgSize(diagram, height, width, conf.useMaxWidth);
-  const vBox = `${
-    svgBounds.x -
-    padding -
-    (gitGraphConfig.showBranches && gitGraphConfig.rotateCommitLabel === true ? 30 : 0)
-  } ${svgBounds.y - padding} ${width} ${height}`;
-  diagram.attr('viewBox', vBox);
+   // Setup the view box and size of the svg element
+    setupGraphViewbox(undefined, diagram, gitGraphConfig.diagramPadding, conf.useMaxWidth);
 };
 
 export default {

From 8c4808a681f87aca40ca2cb291c97f1322a95de5 Mon Sep 17 00:00:00 2001
From: ashishj 
Date: Tue, 13 Sep 2022 18:27:25 +0200
Subject: [PATCH 02/13] #3409 Clean up dead code

---
 src/diagrams/git/gitGraphRenderer.js | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/src/diagrams/git/gitGraphRenderer.js b/src/diagrams/git/gitGraphRenderer.js
index 79339d727..ef85dcb97 100644
--- a/src/diagrams/git/gitGraphRenderer.js
+++ b/src/diagrams/git/gitGraphRenderer.js
@@ -4,7 +4,6 @@ import { log } from '../../logger';
 import addSVGAccessibilityFields from '../../accessibility';
 
 let allCommitsDict = {};
-let branchNum;
 
 const commitType = {
   NORMAL: 0,
@@ -82,7 +81,7 @@ const drawCommits = (svg, commits, modifyGraph) => {
   const sortedKeys = keys.sort((a, b) => {
     return commits[a].seq - commits[b].seq;
   });
-  sortedKeys.forEach((key, index) => {
+  sortedKeys.forEach((key) => {
     const commit = commits[key];
 
     const y = branchPos[commit.branch].pos;
@@ -298,9 +297,6 @@ const drawCommits = (svg, commits, modifyGraph) => {
  * @returns {boolean} if there are commits between commit1's x-position and commit2's x-position
  */
 const hasOverlappingCommits = (commit1, commit2, allCommits) => {
-  const commit1Pos = commitPos[commit2.id];
-  const commit2Pos = commitPos[commit1.id];
-
   // Find commits on the same branch as commit2
   const keys = Object.keys(allCommits);
   const overlappingComits = keys.filter((key) => {

From 4c5d813e585dbc7d40950b80da60c1d1d5b82193 Mon Sep 17 00:00:00 2001
From: ashishj 
Date: Fri, 16 Sep 2022 09:25:22 +0200
Subject: [PATCH 03/13] Fixed Linting issues

---
 cypress/platform/gitgraph.html       |  2 +-
 src/diagrams/git/gitGraphRenderer.js | 14 +++++++-------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/cypress/platform/gitgraph.html b/cypress/platform/gitgraph.html
index d8d16f6c9..0186d6209 100644
--- a/cypress/platform/gitgraph.html
+++ b/cypress/platform/gitgraph.html
@@ -155,7 +155,7 @@
         // arrowMarkerAbsolute: true,
         // themeCSS: '.edgePath .path {stroke: red;} .arrowheadPath {fill: red;}',
         logLevel: 1,
-        gitGraph: {rotateCommitLabel: false},
+        gitGraph: { rotateCommitLabel: false },
         flowchart: { curve: 'linear', htmlLabels: true },
         // gantt: { axisFormat: '%m/%d/%Y' },
         sequence: { actorMargin: 50, showSequenceNumbers: true },
diff --git a/src/diagrams/git/gitGraphRenderer.js b/src/diagrams/git/gitGraphRenderer.js
index ef85dcb97..811a7f85c 100644
--- a/src/diagrams/git/gitGraphRenderer.js
+++ b/src/diagrams/git/gitGraphRenderer.js
@@ -1,5 +1,5 @@
 import { select } from 'd3';
-import { getConfig,setupGraphViewbox } from '../../diagram-api/diagramAPI';
+import { getConfig, setupGraphViewbox } from '../../diagram-api/diagramAPI';
 import { log } from '../../logger';
 import addSVGAccessibilityFields from '../../accessibility';
 
@@ -288,13 +288,13 @@ const drawCommits = (svg, commits, modifyGraph) => {
 };
 
 /**
- * Detect if there are other commits between commit1's x-position and commit2's x-position on the same
- * branch as commit2.
+ * Detect if there are other commits between commit1's x-position and commit2's x-position on the
+ * same branch as commit2.
  *
  * @param {any} commit1
  * @param {any} commit2
  * @param allCommits
- * @returns {boolean} if there are commits between commit1's x-position and commit2's x-position
+ * @returns {boolean} If there are commits between commit1's x-position and commit2's x-position
  */
 const hasOverlappingCommits = (commit1, commit2, allCommits) => {
   // Find commits on the same branch as commit2
@@ -317,7 +317,7 @@ const hasOverlappingCommits = (commit1, commit2, allCommits) => {
  * @param {any} y1
  * @param {any} y2
  * @param {any} _depth
- * @returns {number} y value between y1 and y2
+ * @returns {number} Y value between y1 and y2
  */
 const findLane = (y1, y2, _depth) => {
   const depth = _depth || 0;
@@ -537,8 +537,8 @@ export const draw = function (txt, id, ver, diagObj) {
   drawArrows(diagram, allCommitsDict);
   drawCommits(diagram, allCommitsDict, true);
 
-   // Setup the view box and size of the svg element
-    setupGraphViewbox(undefined, diagram, gitGraphConfig.diagramPadding, conf.useMaxWidth);
+  // Setup the view box and size of the svg element
+  setupGraphViewbox(undefined, diagram, gitGraphConfig.diagramPadding, conf.useMaxWidth);
 };
 
 export default {

From 27e40248ff50a465f7ed4e00406eefa7a0ad23a7 Mon Sep 17 00:00:00 2001
From: Sidharth Vinod 
Date: Fri, 16 Sep 2022 19:39:38 +0530
Subject: [PATCH 04/13] Cleanup docs

---
 docs/index.html | 1 -
 1 file changed, 1 deletion(-)

diff --git a/docs/index.html b/docs/index.html
index 0a41b516c..22892d60b 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -15,7 +15,6 @@
       name="viewport"
       content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
     />
-    
     
     
Date: Fri, 16 Sep 2022 19:55:30 +0530
Subject: [PATCH 05/13] Test docs:verify

---
 src/docs/classDiagram.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/docs/classDiagram.md b/src/docs/classDiagram.md
index 87d76cd37..f46d3689c 100644
--- a/src/docs/classDiagram.md
+++ b/src/docs/classDiagram.md
@@ -493,14 +493,14 @@ It is also possible to attach a class to a list of nodes in one statement:
 
 A shorter form of adding a class is to attach the classname to the node using the `:::` operator:
 
-```mmd
+```mermaid-example
 classDiagram
     class Animal:::cssClass
 ```
 
 Or:
 
-```mmd
+```mermaid-example
 classDiagram
     class Animal:::cssClass {
         -int sizeInFeet

From ae920eaa9384a9f11f8aff11ba73968f19e59c27 Mon Sep 17 00:00:00 2001
From: Elliot Nelson 
Date: Sat, 17 Sep 2022 23:57:32 -0400
Subject: [PATCH 06/13] feat(git): cherry-pick keyword supports tag attribute

---
 .../integration/rendering/gitGraph.spec.js    | 23 ++++++++++--
 docs/gitgraph.md                              | 36 +++++++++++++++++++
 src/diagrams/git/gitGraphAst.js               |  8 +++--
 src/diagrams/git/parser/gitGraph.jison        |  4 ++-
 4 files changed, 65 insertions(+), 6 deletions(-)

diff --git a/cypress/integration/rendering/gitGraph.spec.js b/cypress/integration/rendering/gitGraph.spec.js
index b0d65d0cc..3331f0d33 100644
--- a/cypress/integration/rendering/gitGraph.spec.js
+++ b/cypress/integration/rendering/gitGraph.spec.js
@@ -180,7 +180,27 @@ describe('Git Graph diagram', () => {
       {}
     );
   });
-
+  it('11: should render a gitgraph with cherry pick commit with custom tag', () => {
+    imgSnapshotTest(
+      `
+    gitGraph
+       commit id: "ZERO"
+       branch develop
+       commit id:"A"
+       checkout main
+       commit id:"ONE"
+       checkout develop
+       commit id:"B"
+       checkout main
+       commit id:"TWO"
+       cherry-pick id:"A" tag: "snapshot"
+       commit id:"THREE"
+       checkout develop
+       commit id:"C"
+      `,
+      {}
+    );
+  });
   it('11: should render a simple gitgraph with two cherry pick commit', () => {
     imgSnapshotTest(
       `
@@ -207,7 +227,6 @@ describe('Git Graph diagram', () => {
       {}
     );
   });
-
   it('12: should render commits for more than 8 branches', () => {
     imgSnapshotTest(
       `
diff --git a/docs/gitgraph.md b/docs/gitgraph.md
index 5f86cf53c..bdf2f3a5a 100644
--- a/docs/gitgraph.md
+++ b/docs/gitgraph.md
@@ -393,6 +393,42 @@ Let see an example:
        commit id:"C"
 ```
 
+By default, the cherry-picked commit from commit with id `A` will be labeled `cherry-pick:A`. You can provide your own custom tag instead to override this behavior, using the same syntax as the `commit` keyword:
+
+```mermaid-example
+    gitGraph
+       commit id: "ZERO"
+       branch develop
+       commit id:"A"
+       checkout main
+       commit id:"ONE"
+       checkout develop
+       commit id:"B"
+       checkout main
+       commit id:"TWO"
+       cherry-pick id:"A" tag:"fix"
+       commit id:"THREE"
+       checkout develop
+       commit id:"C"
+```
+
+```mermaid
+    gitGraph
+       commit id: "ZERO"
+       branch develop
+       commit id:"A"
+       checkout main
+       commit id:"ONE"
+       checkout develop
+       commit id:"B"
+       checkout main
+       commit id:"TWO"
+       cherry-pick id:"A" tag:"fix"
+       commit id:"THREE"
+       checkout develop
+       commit id:"C"
+```
+
 ## Gitgraph specific configuration options
 
 In Mermaid, you have the option to configure the gitgraph diagram. You can configure the following options:
diff --git a/src/diagrams/git/gitGraphAst.js b/src/diagrams/git/gitGraphAst.js
index fb9bb100d..e222a046b 100644
--- a/src/diagrams/git/gitGraphAst.js
+++ b/src/diagrams/git/gitGraphAst.js
@@ -258,9 +258,11 @@ export const merge = function (otherBranch, custom_id, override_type, custom_tag
   log.debug('in mergeBranch');
 };
 
-export const cherryPick = function (sourceId, targetId) {
+export const cherryPick = function (sourceId, targetId, tag) {
+  log.debug('Entering cherryPick:', sourceId, targetId, tag);
   sourceId = common.sanitizeText(sourceId, configApi.getConfig());
   targetId = common.sanitizeText(targetId, configApi.getConfig());
+  tag = common.sanitizeText(tag, configApi.getConfig());
 
   if (!sourceId || typeof commits[sourceId] === 'undefined') {
     let error = new Error(
@@ -328,13 +330,13 @@ export const cherryPick = function (sourceId, targetId) {
       parents: [head == null ? null : head.id, sourceCommit.id],
       branch: curBranch,
       type: commitType.CHERRY_PICK,
-      tag: 'cherry-pick:' + sourceCommit.id,
+      tag: tag ? tag : 'cherry-pick:' + sourceCommit.id,
     };
     head = commit;
     commits[commit.id] = commit;
     branches[curBranch] = commit.id;
     log.debug(branches);
-    log.debug('in cheeryPick');
+    log.debug('in cherryPick');
   }
 };
 export const checkout = function (branch) {
diff --git a/src/diagrams/git/parser/gitGraph.jison b/src/diagrams/git/parser/gitGraph.jison
index f35dbcde3..b3fb805af 100644
--- a/src/diagrams/git/parser/gitGraph.jison
+++ b/src/diagrams/git/parser/gitGraph.jison
@@ -117,7 +117,9 @@ branchStatement
     ;
 
 cherryPickStatement
-    : CHERRY_PICK COMMIT_ID STR {yy.cherryPick($3)}
+    : CHERRY_PICK COMMIT_ID STR {yy.cherryPick($3, '')}
+    | CHERRY_PICK COMMIT_ID STR COMMIT_TAG STR {yy.cherryPick($3, $4)}
+    | CHERRY_PICK COMMIT_TAG STR COMMIT_ID STR {yy.cherryPick($4, $3)}
     ;
 
 mergeStatement

From c39a6f27d47f4ea0f67e8a58d31ae717902c6794 Mon Sep 17 00:00:00 2001
From: Alois Klink 
Date: Sun, 18 Sep 2022 06:59:44 +0100
Subject: [PATCH 07/13] test(git): add basic parsing test for cherry-pick

Currently, cherry-pick in gitGraphs only has e2e tests,
no parsing unit tests.
---
 src/diagrams/git/gitGraphParserV2.spec.js | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/diagrams/git/gitGraphParserV2.spec.js b/src/diagrams/git/gitGraphParserV2.spec.js
index b6c9c2459..8db1d6074 100644
--- a/src/diagrams/git/gitGraphParserV2.spec.js
+++ b/src/diagrams/git/gitGraphParserV2.spec.js
@@ -611,6 +611,22 @@ describe('when parsing a gitGraph', function () {
     ]);
   });
 
+  it('should support cherry-picking commits', function () {
+    const str = `gitGraph
+    commit id: "ZERO"
+    branch develop
+    commit id:"A"
+    checkout main
+    cherry-pick id:"A"
+    `;
+
+    parser.parse(str);
+    const commits = parser.yy.getCommits();
+    const cherryPickCommitID = Object.keys(commits)[2];
+    expect(commits[cherryPickCommitID].tag).toBe('cherry-pick:A');
+    expect(commits[cherryPickCommitID].branch).toBe('main');
+  });
+
   it('should throw error when try to branch existing branch: main', function () {
     const str = `gitGraph
     commit

From aba458b832bd85f25d5c5b205500c16bb93c6eb3 Mon Sep 17 00:00:00 2001
From: Alois Klink 
Date: Sun, 18 Sep 2022 07:00:55 +0100
Subject: [PATCH 08/13] fix(git): fix cherry-pick regex parsing error

I forgot to escape the `-` character in a regex statement.

Fixes: 152795666932cf92af33635d2f98dcbe93e911ba
---
 src/diagrams/git/parser/gitGraph.jison | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/diagrams/git/parser/gitGraph.jison b/src/diagrams/git/parser/gitGraph.jison
index f35dbcde3..a7a10912b 100644
--- a/src/diagrams/git/parser/gitGraph.jison
+++ b/src/diagrams/git/parser/gitGraph.jison
@@ -47,7 +47,7 @@ commit(?=\s|$)                          return 'COMMIT';
 branch(?=\s|$)                          return 'BRANCH';
 "order:"                                return 'ORDER';
 merge(?=\s|$)                           return 'MERGE';
-cherry-pick(?=\s|$)                     return 'CHERRY_PICK';
+cherry\-pick(?=\s|$)                    return 'CHERRY_PICK';
 // "reset"                                 return 'RESET';
 checkout(?=\s|$)                        return 'CHECKOUT';
 "LR"                                    return 'DIR';

From 4f96116c43257d7e34e5d09b2c8db524e8e51156 Mon Sep 17 00:00:00 2001
From: Elliot Nelson 
Date: Sun, 18 Sep 2022 08:59:47 -0400
Subject: [PATCH 09/13] Update src/diagrams/git/parser/gitGraph.jison

Co-authored-by: Alois Klink 
---
 src/diagrams/git/parser/gitGraph.jison | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/diagrams/git/parser/gitGraph.jison b/src/diagrams/git/parser/gitGraph.jison
index b3fb805af..18eca1f08 100644
--- a/src/diagrams/git/parser/gitGraph.jison
+++ b/src/diagrams/git/parser/gitGraph.jison
@@ -117,9 +117,9 @@ branchStatement
     ;
 
 cherryPickStatement
-    : CHERRY_PICK COMMIT_ID STR {yy.cherryPick($3, '')}
-    | CHERRY_PICK COMMIT_ID STR COMMIT_TAG STR {yy.cherryPick($3, $4)}
-    | CHERRY_PICK COMMIT_TAG STR COMMIT_ID STR {yy.cherryPick($4, $3)}
+    : CHERRY_PICK COMMIT_ID STR {yy.cherryPick($3, '', '')}
+    | CHERRY_PICK COMMIT_ID STR COMMIT_TAG STR {yy.cherryPick($3, '', $5)}
+    | CHERRY_PICK COMMIT_TAG STR COMMIT_ID STR {yy.cherryPick($5, '', $3)}
     ;
 
 mergeStatement

From 4e4b5ccf8d4cd08a4d2174784802ff159e6e9a7d Mon Sep 17 00:00:00 2001
From: Elliot Nelson 
Date: Sun, 18 Sep 2022 09:22:35 -0400
Subject: [PATCH 10/13] feat(git): allow cherry-pick to suppress tag altogether

---
 .../integration/rendering/gitGraph.spec.js    | 21 +++++++++++++++++++
 docs/gitgraph.md                              |  2 ++
 src/diagrams/git/gitGraphAst.js               |  6 +++++-
 src/diagrams/git/parser/gitGraph.jison        |  2 +-
 4 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/cypress/integration/rendering/gitGraph.spec.js b/cypress/integration/rendering/gitGraph.spec.js
index 3331f0d33..afb39b62e 100644
--- a/cypress/integration/rendering/gitGraph.spec.js
+++ b/cypress/integration/rendering/gitGraph.spec.js
@@ -201,6 +201,27 @@ describe('Git Graph diagram', () => {
       {}
     );
   });
+  it('11: should render a gitgraph with cherry pick commit with no tag', () => {
+    imgSnapshotTest(
+      `
+    gitGraph
+       commit id: "ZERO"
+       branch develop
+       commit id:"A"
+       checkout main
+       commit id:"ONE"
+       checkout develop
+       commit id:"B"
+       checkout main
+       commit id:"TWO"
+       cherry-pick id:"A" tag: ""
+       commit id:"THREE"
+       checkout develop
+       commit id:"C"
+      `,
+      {}
+    );
+  });
   it('11: should render a simple gitgraph with two cherry pick commit', () => {
     imgSnapshotTest(
       `
diff --git a/docs/gitgraph.md b/docs/gitgraph.md
index bdf2f3a5a..863681085 100644
--- a/docs/gitgraph.md
+++ b/docs/gitgraph.md
@@ -429,6 +429,8 @@ By default, the cherry-picked commit from commit with id `A` will be labeled `ch
        commit id:"C"
 ```
 
+To suppress the tag entirely, use `tag:""` (empty string).
+
 ## Gitgraph specific configuration options
 
 In Mermaid, you have the option to configure the gitgraph diagram. You can configure the following options:
diff --git a/src/diagrams/git/gitGraphAst.js b/src/diagrams/git/gitGraphAst.js
index e222a046b..3a6260d4f 100644
--- a/src/diagrams/git/gitGraphAst.js
+++ b/src/diagrams/git/gitGraphAst.js
@@ -262,6 +262,10 @@ export const cherryPick = function (sourceId, targetId, tag) {
   log.debug('Entering cherryPick:', sourceId, targetId, tag);
   sourceId = common.sanitizeText(sourceId, configApi.getConfig());
   targetId = common.sanitizeText(targetId, configApi.getConfig());
+
+  if (tag === 'cherry-pick:') {
+    tag = 'cherry-pick:' + sourceCommit.id;
+  }
   tag = common.sanitizeText(tag, configApi.getConfig());
 
   if (!sourceId || typeof commits[sourceId] === 'undefined') {
@@ -330,7 +334,7 @@ export const cherryPick = function (sourceId, targetId, tag) {
       parents: [head == null ? null : head.id, sourceCommit.id],
       branch: curBranch,
       type: commitType.CHERRY_PICK,
-      tag: tag ? tag : 'cherry-pick:' + sourceCommit.id,
+      tag: tag,
     };
     head = commit;
     commits[commit.id] = commit;
diff --git a/src/diagrams/git/parser/gitGraph.jison b/src/diagrams/git/parser/gitGraph.jison
index 18eca1f08..057186dee 100644
--- a/src/diagrams/git/parser/gitGraph.jison
+++ b/src/diagrams/git/parser/gitGraph.jison
@@ -117,7 +117,7 @@ branchStatement
     ;
 
 cherryPickStatement
-    : CHERRY_PICK COMMIT_ID STR {yy.cherryPick($3, '', '')}
+    : CHERRY_PICK COMMIT_ID STR {yy.cherryPick($3, '', 'cherry-pick:')}
     | CHERRY_PICK COMMIT_ID STR COMMIT_TAG STR {yy.cherryPick($3, '', $5)}
     | CHERRY_PICK COMMIT_TAG STR COMMIT_ID STR {yy.cherryPick($5, '', $3)}
     ;

From 9cbacb01590cf2824da5436ce5d1ab9ac407189d Mon Sep 17 00:00:00 2001
From: Elliot Nelson 
Date: Sun, 18 Sep 2022 16:25:10 -0400
Subject: [PATCH 11/13] Use undefined to mean default tagging behavior

---
 src/diagrams/git/gitGraphAst.js        | 6 +-----
 src/diagrams/git/parser/gitGraph.jison | 2 +-
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/diagrams/git/gitGraphAst.js b/src/diagrams/git/gitGraphAst.js
index 3a6260d4f..41130c780 100644
--- a/src/diagrams/git/gitGraphAst.js
+++ b/src/diagrams/git/gitGraphAst.js
@@ -262,10 +262,6 @@ export const cherryPick = function (sourceId, targetId, tag) {
   log.debug('Entering cherryPick:', sourceId, targetId, tag);
   sourceId = common.sanitizeText(sourceId, configApi.getConfig());
   targetId = common.sanitizeText(targetId, configApi.getConfig());
-
-  if (tag === 'cherry-pick:') {
-    tag = 'cherry-pick:' + sourceCommit.id;
-  }
   tag = common.sanitizeText(tag, configApi.getConfig());
 
   if (!sourceId || typeof commits[sourceId] === 'undefined') {
@@ -334,7 +330,7 @@ export const cherryPick = function (sourceId, targetId, tag) {
       parents: [head == null ? null : head.id, sourceCommit.id],
       branch: curBranch,
       type: commitType.CHERRY_PICK,
-      tag: tag,
+      tag: tag ?? 'cherry-pick:' + sourceCommit.id,
     };
     head = commit;
     commits[commit.id] = commit;
diff --git a/src/diagrams/git/parser/gitGraph.jison b/src/diagrams/git/parser/gitGraph.jison
index 68b6a7af5..74d785f83 100644
--- a/src/diagrams/git/parser/gitGraph.jison
+++ b/src/diagrams/git/parser/gitGraph.jison
@@ -117,7 +117,7 @@ branchStatement
     ;
 
 cherryPickStatement
-    : CHERRY_PICK COMMIT_ID STR {yy.cherryPick($3, '', 'cherry-pick:')}
+    : CHERRY_PICK COMMIT_ID STR {yy.cherryPick($3, '', undefined)}
     | CHERRY_PICK COMMIT_ID STR COMMIT_TAG STR {yy.cherryPick($3, '', $5)}
     | CHERRY_PICK COMMIT_TAG STR COMMIT_ID STR {yy.cherryPick($5, '', $3)}
     ;

From 183fc35fea95d9d78bf9b9c1200d6ee33cc4035b Mon Sep 17 00:00:00 2001
From: Elliot Nelson 
Date: Mon, 19 Sep 2022 00:04:23 -0400
Subject: [PATCH 12/13] Support EMPTYSTR in jison parser, add unit tests for
 git graph parser

---
 src/diagrams/git/gitGraphParserV2.spec.js | 32 +++++++++++++++++++++++
 src/diagrams/git/parser/gitGraph.jison    |  3 +++
 2 files changed, 35 insertions(+)

diff --git a/src/diagrams/git/gitGraphParserV2.spec.js b/src/diagrams/git/gitGraphParserV2.spec.js
index 8db1d6074..7aab8fc7c 100644
--- a/src/diagrams/git/gitGraphParserV2.spec.js
+++ b/src/diagrams/git/gitGraphParserV2.spec.js
@@ -627,6 +627,38 @@ describe('when parsing a gitGraph', function () {
     expect(commits[cherryPickCommitID].branch).toBe('main');
   });
 
+  it('should support cherry-picking commits with custom tag', function () {
+    const str = `gitGraph
+    commit id: "ZERO"
+    branch develop
+    commit id:"A"
+    checkout main
+    cherry-pick id:"A" tag:"MyTag"
+    `;
+
+    parser.parse(str);
+    const commits = parser.yy.getCommits();
+    const cherryPickCommitID = Object.keys(commits)[2];
+    expect(commits[cherryPickCommitID].tag).toBe('MyTag');
+    expect(commits[cherryPickCommitID].branch).toBe('main');
+  });
+
+  it('should support cherry-picking commits with no tag', function () {
+    const str = `gitGraph
+    commit id: "ZERO"
+    branch develop
+    commit id:"A"
+    checkout main
+    cherry-pick id:"A" tag:""
+    `;
+
+    parser.parse(str);
+    const commits = parser.yy.getCommits();
+    const cherryPickCommitID = Object.keys(commits)[2];
+    expect(commits[cherryPickCommitID].tag).toBe('');
+    expect(commits[cherryPickCommitID].branch).toBe('main');
+  });
+
   it('should throw error when try to branch existing branch: main', function () {
     const str = `gitGraph
     commit
diff --git a/src/diagrams/git/parser/gitGraph.jison b/src/diagrams/git/parser/gitGraph.jison
index 74d785f83..dbe220e15 100644
--- a/src/diagrams/git/parser/gitGraph.jison
+++ b/src/diagrams/git/parser/gitGraph.jison
@@ -57,6 +57,7 @@ checkout(?=\s|$)                        return 'CHECKOUT';
 "options"\r?\n                          this.begin("options"); //
 [ \r\n\t]+"end"                this.popState();       // not used anymore in the renderer, fixed for backward compatibility
 [\s\S]+(?=[ \r\n\t]+"end")     return 'OPT';          //
+["]["]                                  return 'EMPTYSTR';
 ["]                                     this.begin("string");
 ["]                             this.popState();
 [^"]*                           return 'STR';
@@ -119,7 +120,9 @@ branchStatement
 cherryPickStatement
     : CHERRY_PICK COMMIT_ID STR {yy.cherryPick($3, '', undefined)}
     | CHERRY_PICK COMMIT_ID STR COMMIT_TAG STR {yy.cherryPick($3, '', $5)}
+    | CHERRY_PICK COMMIT_ID STR COMMIT_TAG EMPTYSTR {yy.cherryPick($3, '', '')}
     | CHERRY_PICK COMMIT_TAG STR COMMIT_ID STR {yy.cherryPick($5, '', $3)}
+    | CHERRY_PICK COMMIT_TAG EMPTYSTR COMMIT_ID STR {yy.cherryPick($3, '', '')}
     ;
 
 mergeStatement

From 8e3f9868ebf4c275f28d98329f111c4ac02f3965 Mon Sep 17 00:00:00 2001
From: mmorel-35 
Date: Mon, 19 Sep 2022 07:18:46 +0000
Subject: [PATCH 13/13] chore: update browsers list

---
 yarn.lock | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/yarn.lock b/yarn.lock
index d09bf07ad..0d2aeda30 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -4087,15 +4087,10 @@ camelcase@^6.2.0:
   resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.2.0.tgz#924af881c9d525ac9d87f40d964e5cea982a1809"
   integrity sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg==
 
-caniuse-lite@^1.0.30001359:
-  version "1.0.30001397"
-  resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001397.tgz"
-  integrity sha512-SW9N2TbCdLf0eiNDRrrQXx2sOkaakNZbCjgNpPyMJJbiOrU5QzMIrXOVMRM1myBXTD5iTkdrtU/EguCrBocHlA==
-
-caniuse-lite@^1.0.30001400:
-  version "1.0.30001402"
-  resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001402.tgz#aa29e1f47f5055b0d0c07696a67b8b08023d14c8"
-  integrity sha512-Mx4MlhXO5NwuvXGgVb+hg65HZ+bhUYsz8QtDGDo2QmaJS2GBX47Xfi2koL86lc8K+l+htXeTEB/Aeqvezoo6Ew==
+caniuse-lite@^1.0.30001359, caniuse-lite@^1.0.30001400:
+  version "1.0.30001406"
+  resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001406.tgz"
+  integrity sha512-bWTlaXUy/rq0BBtYShc/jArYfBPjEV95euvZ8JVtO43oQExEN/WquoqpufFjNu4kSpi5cy5kMbNvzztWDfv1Jg==
 
 capture-exit@^2.0.0:
   version "2.0.0"