From c49a1bf60c5502021a2a97aabed4b950ef11b101 Mon Sep 17 00:00:00 2001 From: Austin Fulbright Date: Sat, 10 Aug 2024 12:28:24 -0400 Subject: [PATCH] fixed custom type REVERSE for merge, fixed branch spacing for TB --- packages/mermaid/src/diagrams/git/gitGraphRenderer.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts b/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts index dde171a628..ecf0f07670 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts @@ -248,7 +248,7 @@ const drawCommitBullet = ( circle.attr('cy', commitPosition.y); circle.attr('r', commit.type === commitType.MERGE ? 9 : 10); circle.attr('class', `commit ${commit.id} commit${branchIndex % THEME_COLOR_LIMIT}`); - if (commit.type === commitType.MERGE) { + if (commitSymbolType === commitType.MERGE) { const circle2 = gBullets.append('circle'); circle2.attr('cx', commitPosition.x); circle2.attr('cy', commitPosition.y); @@ -266,6 +266,7 @@ const drawCommitBullet = ( `M ${commitPosition.x - 5},${commitPosition.y - 5}L${commitPosition.x + 5},${commitPosition.y + 5}M${commitPosition.x - 5},${commitPosition.y + 5}L${commitPosition.x + 5},${commitPosition.y - 5}` ) .attr('class', `commit ${typeClass} ${commit.id} commit${branchIndex % THEME_COLOR_LIMIT}`); + log.info(); } } }; @@ -543,6 +544,7 @@ const drawCommits = ( if (modifyGraph) { const typeClass = getCommitClassType(commit); const commitSymbolType = commit.customType ?? commit.type; + log.info('commitSymbolType', commitSymbolType); const branchIndex = branchPos.get(commit.branch)?.index ?? 0; drawCommitBullet(gBullets, commit, commitPosition, typeClass, branchIndex, commitSymbolType); drawCommitLabel(gLabels, commit, commitPosition, pos, gitGraphConfig); @@ -883,6 +885,9 @@ const setBranchPosition = function ( ): number { branchPos.set(name, { pos, index }); pos += 50 + (rotateCommitLabel ? 40 : 0) + (dir === 'TB' || dir === 'BT' ? bbox.width / 2 : 0); + log.info('bbox.width', bbox.width); + log.info('setBranchPosition', name, pos, index, bbox); + log.info('branchPos', branchPos); return pos; }; @@ -908,7 +913,9 @@ export const draw: DrawDefinition = function (txt, id, ver, diagObj) { const g = diagram.append('g'); const branchLabel = g.insert('g').attr('class', 'branchLabel'); const label = branchLabel.insert('g').attr('class', 'label branch-label'); + label.node()?.appendChild(labelElement); const bbox = labelElement.getBBox(); + pos = setBranchPosition(branch.name, pos, index, bbox, rotateCommitLabel); label.remove(); branchLabel.remove();