Merge pull request #5647 from mermaid-js/fix/3801

feat(3801): Multiple Tags support for Git Graph
This commit is contained in:
Sidharth Vinod
2024-07-18 21:50:11 +05:30
committed by GitHub
6 changed files with 266 additions and 214 deletions

View File

@@ -1532,5 +1532,41 @@ gitGraph TB:
{} {}
); );
}); });
it('75: should render a gitGraph with multiple tags on a merge commit on bottom-to-top orientation', () => {
imgSnapshotTest(
`gitGraph BT:
commit id: "ZERO"
branch develop
commit id:"A"
checkout main
commit id:"ONE"
checkout develop
commit id:"B"
checkout main
merge develop id:"Release 1.0" type:HIGHLIGHT tag: "SAML v2.0" tag: "OpenID v1.1"
commit id:"TWO"
checkout develop
commit id:"C"`,
{}
);
});
});
it('76: should render a gitGraph with multiple tags on a merge commit on left-to-right orientation', () => {
imgSnapshotTest(
`gitGraph
commit id: "ZERO"
branch develop
commit id:"A"
checkout main
commit id:"ONE"
checkout develop
commit id:"B"
checkout main
merge develop id:"Release 1.0" type:HIGHLIGHT tag: "SAML v2.0" tag: "OpenID v1.1"
commit id:"TWO"
checkout develop
commit id:"C"`,
{}
);
}); });
}); });

View File

@@ -12,8 +12,7 @@ import {
getDiagramTitle, getDiagramTitle,
} from '../common/commonDb.js'; } from '../common/commonDb.js';
let mainBranchName = getConfig().gitGraph.mainBranchName; let { mainBranchName, mainBranchOrder } = getConfig().gitGraph;
let mainBranchOrder = getConfig().gitGraph.mainBranchOrder;
let commits = new Map(); let commits = new Map();
let head = null; let head = null;
let branchesConfig = new Map(); let branchesConfig = new Map();
@@ -103,17 +102,18 @@ export const getOptions = function () {
return options; return options;
}; };
export const commit = function (msg, id, type, tag) { export const commit = function (msg, id, type, tags) {
log.debug('Entering commit:', msg, id, type, tag); log.debug('Entering commit:', msg, id, type, tags);
id = common.sanitizeText(id, getConfig()); const config = getConfig();
msg = common.sanitizeText(msg, getConfig()); id = common.sanitizeText(id, config);
tag = common.sanitizeText(tag, getConfig()); msg = common.sanitizeText(msg, config);
tags = tags?.map((tag) => common.sanitizeText(tag, config));
const commit = { const commit = {
id: id ? id : seq + '-' + getId(), id: id ? id : seq + '-' + getId(),
message: msg, message: msg,
seq: seq++, seq: seq++,
type: type ? type : commitType.NORMAL, type: type ? type : commitType.NORMAL,
tag: tag ? tag : '', tags: tags ?? [],
parents: head == null ? [] : [head.id], parents: head == null ? [] : [head.id],
branch: curBranch, branch: curBranch,
}; };
@@ -147,9 +147,10 @@ export const branch = function (name, order) {
} }
}; };
export const merge = function (otherBranch, custom_id, override_type, custom_tag) { export const merge = function (otherBranch, custom_id, override_type, custom_tags) {
otherBranch = common.sanitizeText(otherBranch, getConfig()); const config = getConfig();
custom_id = common.sanitizeText(custom_id, getConfig()); otherBranch = common.sanitizeText(otherBranch, config);
custom_id = common.sanitizeText(custom_id, config);
const currentCommit = commits.get(branches.get(curBranch)); const currentCommit = commits.get(branches.get(curBranch));
const otherCommit = commits.get(branches.get(otherBranch)); const otherCommit = commits.get(branches.get(otherBranch));
@@ -216,12 +217,12 @@ export const merge = function (otherBranch, custom_id, override_type, custom_tag
' already exists, use different custom Id' ' already exists, use different custom Id'
); );
error.hash = { error.hash = {
text: 'merge ' + otherBranch + custom_id + override_type + custom_tag, text: 'merge ' + otherBranch + custom_id + override_type + custom_tags?.join(','),
token: 'merge ' + otherBranch + custom_id + override_type + custom_tag, token: 'merge ' + otherBranch + custom_id + override_type + custom_tags?.join(','),
line: '1', line: '1',
loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 },
expected: [ expected: [
'merge ' + otherBranch + ' ' + custom_id + '_UNIQUE ' + override_type + ' ' + custom_tag, `merge ${otherBranch} ${custom_id}_UNIQUE ${override_type} ${custom_tags?.join(',')}`,
], ],
}; };
@@ -245,7 +246,7 @@ export const merge = function (otherBranch, custom_id, override_type, custom_tag
type: commitType.MERGE, type: commitType.MERGE,
customType: override_type, customType: override_type,
customId: custom_id ? true : false, customId: custom_id ? true : false,
tag: custom_tag ? custom_tag : '', tags: custom_tags ? custom_tags : [],
}; };
head = commit; head = commit;
commits.set(commit.id, commit); commits.set(commit.id, commit);
@@ -255,12 +256,13 @@ export const merge = function (otherBranch, custom_id, override_type, custom_tag
log.debug('in mergeBranch'); log.debug('in mergeBranch');
}; };
export const cherryPick = function (sourceId, targetId, tag, parentCommitId) { export const cherryPick = function (sourceId, targetId, tags, parentCommitId) {
log.debug('Entering cherryPick:', sourceId, targetId, tag); log.debug('Entering cherryPick:', sourceId, targetId, tags);
sourceId = common.sanitizeText(sourceId, getConfig()); const config = getConfig();
targetId = common.sanitizeText(targetId, getConfig()); sourceId = common.sanitizeText(sourceId, config);
tag = common.sanitizeText(tag, getConfig()); targetId = common.sanitizeText(targetId, config);
parentCommitId = common.sanitizeText(parentCommitId, getConfig()); tags = tags?.map((tag) => common.sanitizeText(tag, config));
parentCommitId = common.sanitizeText(parentCommitId, config);
if (!sourceId || !commits.has(sourceId)) { if (!sourceId || !commits.has(sourceId)) {
let error = new Error( let error = new Error(
@@ -329,11 +331,13 @@ export const cherryPick = function (sourceId, targetId, tag, parentCommitId) {
parents: [head == null ? null : head.id, sourceCommit.id], parents: [head == null ? null : head.id, sourceCommit.id],
branch: curBranch, branch: curBranch,
type: commitType.CHERRY_PICK, type: commitType.CHERRY_PICK,
tag: tags: tags
tag ?? ? tags.filter(Boolean)
: [
`cherry-pick:${sourceCommit.id}${ `cherry-pick:${sourceCommit.id}${
sourceCommit.type === commitType.MERGE ? `|parent:${parentCommitId}` : '' sourceCommit.type === commitType.MERGE ? `|parent:${parentCommitId}` : ''
}`, }`,
],
}; };
head = commit; head = commit;
commits.set(commit.id, commit); commits.set(commit.id, commit);
@@ -356,8 +360,6 @@ export const checkout = function (branch) {
expected: ['"branch ' + branch + '"'], expected: ['"branch ' + branch + '"'],
}; };
throw error; throw error;
//branches[branch] = head != null ? head.id : null;
//log.debug('in createBranch');
} else { } else {
curBranch = branch; curBranch = branch;
const id = branches.get(curBranch); const id = branches.get(curBranch);
@@ -444,13 +446,12 @@ export const prettyPrint = function () {
export const clear = function () { export const clear = function () {
commits = new Map(); commits = new Map();
head = null; head = null;
let mainBranch = getConfig().gitGraph.mainBranchName; const { mainBranchName, mainBranchOrder } = getConfig().gitGraph;
let mainBranchOrder = getConfig().gitGraph.mainBranchOrder;
branches = new Map(); branches = new Map();
branches.set(mainBranch, null); branches.set(mainBranchName, null);
branchesConfig = new Map(); branchesConfig = new Map();
branchesConfig.set(mainBranch, { name: mainBranch, order: mainBranchOrder }); branchesConfig.set(mainBranchName, { name: mainBranchName, order: mainBranchOrder });
curBranch = mainBranch; curBranch = mainBranchName;
seq = 0; seq = 0;
commonClear(); commonClear();
}; };

View File

@@ -20,7 +20,7 @@ describe('when parsing a gitGraph', function () {
const key = commits.keys().next().value; const key = commits.keys().next().value;
expect(commits.get(key).message).toBe(''); expect(commits.get(key).message).toBe('');
expect(commits.get(key).id).not.toBeNull(); expect(commits.get(key).id).not.toBeNull();
expect(commits.get(key).tag).toBe(''); expect(commits.get(key).tags).toStrictEqual([]);
expect(commits.get(key).type).toBe(0); expect(commits.get(key).type).toBe(0);
}); });
@@ -37,7 +37,7 @@ describe('when parsing a gitGraph', function () {
const key = commits.keys().next().value; const key = commits.keys().next().value;
expect(commits.get(key).message).toBe(''); expect(commits.get(key).message).toBe('');
expect(commits.get(key).id).toBe('1111'); expect(commits.get(key).id).toBe('1111');
expect(commits.get(key).tag).toBe(''); expect(commits.get(key).tags).toStrictEqual([]);
expect(commits.get(key).type).toBe(0); expect(commits.get(key).type).toBe(0);
}); });
@@ -55,7 +55,7 @@ describe('when parsing a gitGraph', function () {
const key = commits.keys().next().value; const key = commits.keys().next().value;
expect(commits.get(key).message).toBe(''); expect(commits.get(key).message).toBe('');
expect(commits.get(key).id).not.toBeNull(); expect(commits.get(key).id).not.toBeNull();
expect(commits.get(key).tag).toBe('test'); expect(commits.get(key).tags).toStrictEqual(['test']);
expect(commits.get(key).type).toBe(0); expect(commits.get(key).type).toBe(0);
}); });
@@ -73,7 +73,7 @@ describe('when parsing a gitGraph', function () {
const key = commits.keys().next().value; const key = commits.keys().next().value;
expect(commits.get(key).message).toBe(''); expect(commits.get(key).message).toBe('');
expect(commits.get(key).id).not.toBeNull(); expect(commits.get(key).id).not.toBeNull();
expect(commits.get(key).tag).toBe(''); expect(commits.get(key).tags).toStrictEqual([]);
expect(commits.get(key).type).toBe(2); expect(commits.get(key).type).toBe(2);
}); });
@@ -91,7 +91,7 @@ describe('when parsing a gitGraph', function () {
const key = commits.keys().next().value; const key = commits.keys().next().value;
expect(commits.get(key).message).toBe(''); expect(commits.get(key).message).toBe('');
expect(commits.get(key).id).not.toBeNull(); expect(commits.get(key).id).not.toBeNull();
expect(commits.get(key).tag).toBe(''); expect(commits.get(key).tags).toStrictEqual([]);
expect(commits.get(key).type).toBe(1); expect(commits.get(key).type).toBe(1);
}); });
@@ -109,7 +109,7 @@ describe('when parsing a gitGraph', function () {
const key = commits.keys().next().value; const key = commits.keys().next().value;
expect(commits.get(key).message).toBe(''); expect(commits.get(key).message).toBe('');
expect(commits.get(key).id).not.toBeNull(); expect(commits.get(key).id).not.toBeNull();
expect(commits.get(key).tag).toBe(''); expect(commits.get(key).tags).toStrictEqual([]);
expect(commits.get(key).type).toBe(0); expect(commits.get(key).type).toBe(0);
}); });
@@ -127,7 +127,7 @@ describe('when parsing a gitGraph', function () {
const key = commits.keys().next().value; const key = commits.keys().next().value;
expect(commits.get(key).message).toBe('test commit'); expect(commits.get(key).message).toBe('test commit');
expect(commits.get(key).id).not.toBeNull(); expect(commits.get(key).id).not.toBeNull();
expect(commits.get(key).tag).toBe(''); expect(commits.get(key).tags).toStrictEqual([]);
expect(commits.get(key).type).toBe(0); expect(commits.get(key).type).toBe(0);
}); });
@@ -145,7 +145,7 @@ describe('when parsing a gitGraph', function () {
const key = commits.keys().next().value; const key = commits.keys().next().value;
expect(commits.get(key).message).toBe('test commit'); expect(commits.get(key).message).toBe('test commit');
expect(commits.get(key).id).not.toBeNull(); expect(commits.get(key).id).not.toBeNull();
expect(commits.get(key).tag).toBe(''); expect(commits.get(key).tags).toStrictEqual([]);
expect(commits.get(key).type).toBe(0); expect(commits.get(key).type).toBe(0);
}); });
@@ -163,7 +163,7 @@ describe('when parsing a gitGraph', function () {
const key = commits.keys().next().value; const key = commits.keys().next().value;
expect(commits.get(key).message).toBe(''); expect(commits.get(key).message).toBe('');
expect(commits.get(key).id).toBe('1111'); expect(commits.get(key).id).toBe('1111');
expect(commits.get(key).tag).toBe('test tag'); expect(commits.get(key).tags).toStrictEqual(['test tag']);
expect(commits.get(key).type).toBe(0); expect(commits.get(key).type).toBe(0);
}); });
@@ -181,7 +181,7 @@ describe('when parsing a gitGraph', function () {
const key = commits.keys().next().value; const key = commits.keys().next().value;
expect(commits.get(key).message).toBe(''); expect(commits.get(key).message).toBe('');
expect(commits.get(key).id).not.toBeNull(); expect(commits.get(key).id).not.toBeNull();
expect(commits.get(key).tag).toBe('test tag'); expect(commits.get(key).tags).toStrictEqual(['test tag']);
expect(commits.get(key).type).toBe(2); expect(commits.get(key).type).toBe(2);
}); });
@@ -199,7 +199,7 @@ describe('when parsing a gitGraph', function () {
const key = commits.keys().next().value; const key = commits.keys().next().value;
expect(commits.get(key).message).toBe(''); expect(commits.get(key).message).toBe('');
expect(commits.get(key).id).not.toBeNull(); expect(commits.get(key).id).not.toBeNull();
expect(commits.get(key).tag).toBe('test tag'); expect(commits.get(key).tags).toStrictEqual(['test tag']);
expect(commits.get(key).type).toBe(2); expect(commits.get(key).type).toBe(2);
}); });
@@ -217,7 +217,7 @@ describe('when parsing a gitGraph', function () {
const key = commits.keys().next().value; const key = commits.keys().next().value;
expect(commits.get(key).message).toBe(''); expect(commits.get(key).message).toBe('');
expect(commits.get(key).id).toBe('1111'); expect(commits.get(key).id).toBe('1111');
expect(commits.get(key).tag).toBe('test tag'); expect(commits.get(key).tags).toStrictEqual(['test tag']);
expect(commits.get(key).type).toBe(1); expect(commits.get(key).type).toBe(1);
}); });
@@ -235,7 +235,7 @@ describe('when parsing a gitGraph', function () {
const key = commits.keys().next().value; const key = commits.keys().next().value;
expect(commits.get(key).message).toBe('test msg'); expect(commits.get(key).message).toBe('test msg');
expect(commits.get(key).id).toBe('1111'); expect(commits.get(key).id).toBe('1111');
expect(commits.get(key).tag).toBe('test tag'); expect(commits.get(key).tags).toStrictEqual(['test tag']);
expect(commits.get(key).type).toBe(1); expect(commits.get(key).type).toBe(1);
}); });
@@ -254,7 +254,7 @@ describe('when parsing a gitGraph', function () {
const key = commits.keys().next().value; const key = commits.keys().next().value;
expect(commits.get(key).message).toBe('test msg'); expect(commits.get(key).message).toBe('test msg');
expect(commits.get(key).id).toBe('1111'); expect(commits.get(key).id).toBe('1111');
expect(commits.get(key).tag).toBe('test tag'); expect(commits.get(key).tags).toStrictEqual(['test tag']);
expect(commits.get(key).type).toBe(1); expect(commits.get(key).type).toBe(1);
}); });
@@ -272,7 +272,7 @@ describe('when parsing a gitGraph', function () {
const key = commits.keys().next().value; const key = commits.keys().next().value;
expect(commits.get(key).message).toBe('test msg'); expect(commits.get(key).message).toBe('test msg');
expect(commits.get(key).id).toBe('1111'); expect(commits.get(key).id).toBe('1111');
expect(commits.get(key).tag).toBe('test tag'); expect(commits.get(key).tags).toStrictEqual(['test tag']);
expect(commits.get(key).type).toBe(1); expect(commits.get(key).type).toBe(1);
}); });
@@ -290,7 +290,7 @@ describe('when parsing a gitGraph', function () {
const key = commits.keys().next().value; const key = commits.keys().next().value;
expect(commits.get(key).message).toBe('test msg'); expect(commits.get(key).message).toBe('test msg');
expect(commits.get(key).id).toBe('1111'); expect(commits.get(key).id).toBe('1111');
expect(commits.get(key).tag).toBe('test tag'); expect(commits.get(key).tags).toStrictEqual(['test tag']);
expect(commits.get(key).type).toBe(1); expect(commits.get(key).type).toBe(1);
}); });
@@ -616,7 +616,7 @@ describe('when parsing a gitGraph', function () {
commits.get(commit1).id, commits.get(commit1).id,
commits.get(commit2).id, commits.get(commit2).id,
]); ]);
expect(commits.get(commit3).tag).toBe('merge-tag'); expect(commits.get(commit3).tags).toStrictEqual(['merge-tag']);
expect(parser.yy.getBranchesAsObjArray()).toStrictEqual([ expect(parser.yy.getBranchesAsObjArray()).toStrictEqual([
{ name: 'main' }, { name: 'main' },
{ name: 'testBranch' }, { name: 'testBranch' },
@@ -671,12 +671,12 @@ describe('when parsing a gitGraph', function () {
expect(testBranchMerge.branch).toBe('main'); expect(testBranchMerge.branch).toBe('main');
expect(testBranchMerge.parents).toStrictEqual([mainCommit.id, testBranchCommit.id]); expect(testBranchMerge.parents).toStrictEqual([mainCommit.id, testBranchCommit.id]);
expect(testBranchMerge.tag).toBe('merge-tag'); expect(testBranchMerge.tags).toStrictEqual(['merge-tag']);
expect(testBranchMerge.id).toBe('2-222'); expect(testBranchMerge.id).toBe('2-222');
expect(testBranch2Merge.branch).toBe('main'); expect(testBranch2Merge.branch).toBe('main');
expect(testBranch2Merge.parents).toStrictEqual([testBranchMerge.id, testBranch2Commit.id]); expect(testBranch2Merge.parents).toStrictEqual([testBranchMerge.id, testBranch2Commit.id]);
expect(testBranch2Merge.tag).toBe('merge-tag2'); expect(testBranch2Merge.tags).toStrictEqual(['merge-tag2']);
expect(testBranch2Merge.id).toBe('4-444'); expect(testBranch2Merge.id).toBe('4-444');
expect(testBranch2Merge.customType).toBe(2); expect(testBranch2Merge.customType).toBe(2);
expect(testBranch2Merge.customId).toBe(true); expect(testBranch2Merge.customId).toBe(true);
@@ -705,7 +705,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 = [...commits.keys()][2]; const cherryPickCommitID = [...commits.keys()][2];
expect(commits.get(cherryPickCommitID).tag).toBe('cherry-pick:A'); expect(commits.get(cherryPickCommitID).tags).toStrictEqual(['cherry-pick:A']);
expect(commits.get(cherryPickCommitID).branch).toBe('main'); expect(commits.get(cherryPickCommitID).branch).toBe('main');
}); });
@@ -721,7 +721,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 = [...commits.keys()][2]; const cherryPickCommitID = [...commits.keys()][2];
expect(commits.get(cherryPickCommitID).tag).toBe('MyTag'); expect(commits.get(cherryPickCommitID).tags).toStrictEqual(['MyTag']);
expect(commits.get(cherryPickCommitID).branch).toBe('main'); expect(commits.get(cherryPickCommitID).branch).toBe('main');
}); });
@@ -737,7 +737,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 = [...commits.keys()][2]; const cherryPickCommitID = [...commits.keys()][2];
expect(commits.get(cherryPickCommitID).tag).toBe(''); expect(commits.get(cherryPickCommitID).tags).toStrictEqual([]);
expect(commits.get(cherryPickCommitID).branch).toBe('main'); expect(commits.get(cherryPickCommitID).branch).toBe('main');
}); });
@@ -758,7 +758,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 = [...commits.keys()][4]; const cherryPickCommitID = [...commits.keys()][4];
expect(commits.get(cherryPickCommitID).tag).toBe('cherry-pick:M|parent:B'); expect(commits.get(cherryPickCommitID).tags).toStrictEqual(['cherry-pick:M|parent:B']);
expect(commits.get(cherryPickCommitID).branch).toBe('release'); expect(commits.get(cherryPickCommitID).branch).toBe('release');
}); });
@@ -779,7 +779,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 = [...commits.keys()][4]; const cherryPickCommitID = [...commits.keys()][4];
expect(commits.get(cherryPickCommitID).tag).toBe('v1.0'); expect(commits.get(cherryPickCommitID).tags).toStrictEqual(['v1.0']);
expect(commits.get(cherryPickCommitID).branch).toBe('release'); expect(commits.get(cherryPickCommitID).branch).toBe('release');
}); });
@@ -802,7 +802,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 = [...commits.keys()][5]; const cherryPickCommitID = [...commits.keys()][5];
expect(commits.get(cherryPickCommitID).tag).toBe('v2.1:ZERO'); expect(commits.get(cherryPickCommitID).tags).toStrictEqual(['v2.1:ZERO']);
expect(commits.get(cherryPickCommitID).branch).toBe('release'); expect(commits.get(cherryPickCommitID).branch).toBe('release');
}); });
@@ -827,8 +827,8 @@ describe('when parsing a gitGraph', function () {
const commits = parser.yy.getCommits(); const commits = parser.yy.getCommits();
const cherryPickCommitID = [...commits.keys()][5]; const cherryPickCommitID = [...commits.keys()][5];
const cherryPickCommitID2 = [...commits.keys()][7]; const cherryPickCommitID2 = [...commits.keys()][7];
expect(commits.get(cherryPickCommitID).tag).toBe(''); expect(commits.get(cherryPickCommitID).tags).toStrictEqual([]);
expect(commits.get(cherryPickCommitID2).tag).toBe(''); expect(commits.get(cherryPickCommitID2).tags).toStrictEqual([]);
expect(commits.get(cherryPickCommitID).branch).toBe('release'); expect(commits.get(cherryPickCommitID).branch).toBe('release');
}); });

View File

@@ -414,62 +414,86 @@ const drawCommits = (svg, commits, modifyGraph) => {
} }
} }
} }
if (commit.tag) { if (commit.tags.length > 0) {
let yOffset = 0;
let maxTagBboxWidth = 0;
let maxTagBboxHeight = 0;
const tagElements = [];
for (const tagValue of commit.tags.reverse()) {
const rect = gLabels.insert('polygon'); const rect = gLabels.insert('polygon');
const hole = gLabels.append('circle'); const hole = gLabels.append('circle');
const tag = gLabels const tag = gLabels
.append('text') .append('text')
// Note that we are delaying setting the x position until we know the width of the text // Note that we are delaying setting the x position until we know the width of the text
.attr('y', y - 16) .attr('y', y - 16 - yOffset)
.attr('class', 'tag-label') .attr('class', 'tag-label')
.text(commit.tag); .text(tagValue);
let tagBbox = tag.node().getBBox(); let tagBbox = tag.node().getBBox();
maxTagBboxWidth = Math.max(maxTagBboxWidth, tagBbox.width);
maxTagBboxHeight = Math.max(maxTagBboxHeight, tagBbox.height);
// We don't use the max over here to center the text within the tags
tag.attr('x', posWithOffset - tagBbox.width / 2); tag.attr('x', posWithOffset - tagBbox.width / 2);
const h2 = tagBbox.height / 2; tagElements.push({
const ly = y - 19.2; tag,
hole,
rect,
yOffset,
});
yOffset += 20;
}
for (const { tag, hole, rect, yOffset } of tagElements) {
const h2 = maxTagBboxHeight / 2;
const ly = y - 19.2 - yOffset;
rect.attr('class', 'tag-label-bkg').attr( rect.attr('class', 'tag-label-bkg').attr(
'points', 'points',
` `
${pos - tagBbox.width / 2 - px / 2},${ly + py} ${pos - maxTagBboxWidth / 2 - px / 2},${ly + py}
${pos - tagBbox.width / 2 - px / 2},${ly - py} ${pos - maxTagBboxWidth / 2 - px / 2},${ly - py}
${posWithOffset - tagBbox.width / 2 - px},${ly - h2 - py} ${posWithOffset - maxTagBboxWidth / 2 - px},${ly - h2 - py}
${posWithOffset + tagBbox.width / 2 + px},${ly - h2 - py} ${posWithOffset + maxTagBboxWidth / 2 + px},${ly - h2 - py}
${posWithOffset + tagBbox.width / 2 + px},${ly + h2 + py} ${posWithOffset + maxTagBboxWidth / 2 + px},${ly + h2 + py}
${posWithOffset - tagBbox.width / 2 - px},${ly + h2 + py}` ${posWithOffset - maxTagBboxWidth / 2 - px},${ly + h2 + py}`
); );
hole hole
.attr('cx', pos - tagBbox.width / 2 + px / 2)
.attr('cy', ly) .attr('cy', ly)
.attr('cx', pos - maxTagBboxWidth / 2 + px / 2)
.attr('r', 1.5) .attr('r', 1.5)
.attr('class', 'tag-hole'); .attr('class', 'tag-hole');
if (dir === 'TB' || dir === 'BT') { if (dir === 'TB' || dir === 'BT') {
const yOrigin = pos + yOffset;
rect rect
.attr('class', 'tag-label-bkg') .attr('class', 'tag-label-bkg')
.attr( .attr(
'points', 'points',
` `
${x},${pos + py} ${x},${yOrigin + py}
${x},${pos - py} ${x},${yOrigin - py}
${x + layoutOffset},${pos - h2 - py} ${x + layoutOffset},${yOrigin - h2 - py}
${x + layoutOffset + tagBbox.width + px},${pos - h2 - py} ${x + layoutOffset + maxTagBboxWidth + px},${yOrigin - h2 - py}
${x + layoutOffset + tagBbox.width + px},${pos + h2 + py} ${x + layoutOffset + maxTagBboxWidth + px},${yOrigin + h2 + py}
${x + layoutOffset},${pos + h2 + py}` ${x + layoutOffset},${yOrigin + h2 + py}`
) )
.attr('transform', 'translate(12,12) rotate(45, ' + x + ',' + pos + ')'); .attr('transform', 'translate(12,12) rotate(45, ' + x + ',' + pos + ')');
hole hole
.attr('cx', x + px / 2) .attr('cx', x + px / 2)
.attr('cy', pos) .attr('cy', yOrigin)
.attr('transform', 'translate(12,12) rotate(45, ' + x + ',' + pos + ')'); .attr('transform', 'translate(12,12) rotate(45, ' + x + ',' + pos + ')');
tag tag
.attr('x', x + 5) .attr('x', x + 5)
.attr('y', pos + 3) .attr('y', yOrigin + 3)
.attr('transform', 'translate(14,14) rotate(45, ' + x + ',' + pos + ')'); .attr('transform', 'translate(14,14) rotate(45, ' + x + ',' + pos + ')');
} }
} }
} }
}
pos = dir === 'BT' && isParallelCommits ? pos + commitStep : pos + commitStep + layoutOffset; pos = dir === 'BT' && isParallelCommits ? pos + commitStep : pos + commitStep + layoutOffset;
if (pos > maxPos) { if (pos > maxPos) {
maxPos = pos; maxPos = pos;

View File

@@ -112,122 +112,105 @@ branchStatement
cherryPickStatement cherryPickStatement
: CHERRY_PICK COMMIT_ID STR {yy.cherryPick($3, '', undefined)} : CHERRY_PICK COMMIT_ID STR {yy.cherryPick($3, '', undefined)}
| CHERRY_PICK COMMIT_ID STR PARENT_COMMIT STR {yy.cherryPick($3, '', undefined,$5)} | CHERRY_PICK COMMIT_ID STR PARENT_COMMIT STR {yy.cherryPick($3, '', undefined,$5)}
| CHERRY_PICK COMMIT_ID STR COMMIT_TAG STR {yy.cherryPick($3, '', $5)} | CHERRY_PICK COMMIT_ID STR commitTags {yy.cherryPick($3, '', $4)}
| CHERRY_PICK COMMIT_ID STR PARENT_COMMIT STR COMMIT_TAG STR {yy.cherryPick($3, '', $7,$5)} | CHERRY_PICK COMMIT_ID STR PARENT_COMMIT STR commitTags {yy.cherryPick($3, '', $6,$5)}
| CHERRY_PICK COMMIT_ID STR COMMIT_TAG STR PARENT_COMMIT STR {yy.cherryPick($3, '', $5,$7)} | CHERRY_PICK COMMIT_ID STR commitTags PARENT_COMMIT STR {yy.cherryPick($3, '', $4,$6)}
| CHERRY_PICK COMMIT_TAG STR COMMIT_ID STR {yy.cherryPick($5, '', $3)} | CHERRY_PICK commitTags COMMIT_ID STR {yy.cherryPick($4, '', $2)}
| CHERRY_PICK COMMIT_TAG EMPTYSTR COMMIT_ID STR {yy.cherryPick($5, '', '')} | CHERRY_PICK commitTags COMMIT_ID STR PARENT_COMMIT STR {yy.cherryPick($4, '', $2,$6)}
| CHERRY_PICK COMMIT_ID STR COMMIT_TAG EMPTYSTR {yy.cherryPick($3, '', '')}
| CHERRY_PICK COMMIT_ID STR PARENT_COMMIT STR COMMIT_TAG EMPTYSTR {yy.cherryPick($3, '', '',$5)}
| CHERRY_PICK COMMIT_ID STR COMMIT_TAG EMPTYSTR PARENT_COMMIT STR {yy.cherryPick($3, '', '',$7)}
| CHERRY_PICK COMMIT_TAG STR COMMIT_ID STR PARENT_COMMIT STR {yy.cherryPick($5, '', $3,$7)}
| CHERRY_PICK COMMIT_TAG EMPTYSTR COMMIT_ID STR PARENT_COMMIT STR{yy.cherryPick($5, '', '',$7)}
; ;
mergeStatement mergeStatement
: MERGE ref {yy.merge($2,'','','')} : MERGE ref {yy.merge($2,'','', undefined)}
| MERGE ref COMMIT_ID STR {yy.merge($2, $4,'','')} | MERGE ref COMMIT_ID STR {yy.merge($2, $4,'', undefined)}
| MERGE ref COMMIT_TYPE commitType {yy.merge($2,'', $4,'')} | MERGE ref COMMIT_TYPE commitType {yy.merge($2,'', $4, undefined)}
| MERGE ref COMMIT_TAG STR {yy.merge($2, '','',$4)} | MERGE ref commitTags {yy.merge($2, '','',$3)}
| MERGE ref COMMIT_TAG STR COMMIT_ID STR {yy.merge($2, $6,'', $4)} | MERGE ref commitTags COMMIT_ID STR {yy.merge($2, $5,'', $3)}
| MERGE ref COMMIT_TAG STR COMMIT_TYPE commitType {yy.merge($2, '',$6, $4)} | MERGE ref commitTags COMMIT_TYPE commitType {yy.merge($2, '',$5, $3)}
| MERGE ref COMMIT_TYPE commitType COMMIT_TAG STR {yy.merge($2, '',$4, $6)} | MERGE ref COMMIT_TYPE commitType commitTags {yy.merge($2, '',$4, $5)}
| MERGE ref COMMIT_ID STR COMMIT_TYPE commitType {yy.merge($2, $4, $6, '')} | MERGE ref COMMIT_ID STR COMMIT_TYPE commitType {yy.merge($2, $4, $6, undefined)}
| MERGE ref COMMIT_ID STR COMMIT_TAG STR {yy.merge($2, $4, '', $6)} | MERGE ref COMMIT_ID STR commitTags {yy.merge($2, $4, '', $5)}
| MERGE ref COMMIT_TYPE commitType COMMIT_ID STR {yy.merge($2, $6,$4, '')} | MERGE ref COMMIT_TYPE commitType COMMIT_ID STR {yy.merge($2, $6,$4, undefined)}
| MERGE ref COMMIT_ID STR COMMIT_TYPE commitType COMMIT_TAG STR {yy.merge($2, $4, $6, $8)} | MERGE ref COMMIT_ID STR COMMIT_TYPE commitType commitTags {yy.merge($2, $4, $6, $7)}
| MERGE ref COMMIT_TYPE commitType COMMIT_TAG STR COMMIT_ID STR {yy.merge($2, $8, $4, $6)} | MERGE ref COMMIT_TYPE commitType commitTags COMMIT_ID STR {yy.merge($2, $7, $4, $5)}
| MERGE ref COMMIT_ID STR COMMIT_TAG STR COMMIT_TYPE commitType {yy.merge($2, $4, $8, $6)} | MERGE ref COMMIT_ID STR commitTags COMMIT_TYPE commitType {yy.merge($2, $4, $7, $5)}
| MERGE ref COMMIT_TYPE commitType COMMIT_ID STR COMMIT_TAG STR {yy.merge($2, $6, $4, $8)} | MERGE ref COMMIT_TYPE commitType COMMIT_ID STR commitTags {yy.merge($2, $6, $4, $7)}
| MERGE ref COMMIT_TAG STR COMMIT_TYPE commitType COMMIT_ID STR {yy.merge($2, $8, $6, $4)} | MERGE ref commitTags COMMIT_TYPE commitType COMMIT_ID STR {yy.merge($2, $7, $5, $3)}
| MERGE ref COMMIT_TAG STR COMMIT_ID STR COMMIT_TYPE commitType {yy.merge($2, $6, $8, $4)} | MERGE ref commitTags COMMIT_ID STR COMMIT_TYPE commitType {yy.merge($2, $5, $7, $3)}
; ;
commitStatement commitStatement
: COMMIT commit_arg {yy.commit($2)} : COMMIT commit_arg {yy.commit($2)}
| COMMIT COMMIT_TAG STR {yy.commit('','',yy.commitType.NORMAL,$3)} | COMMIT commitTags {yy.commit('','',yy.commitType.NORMAL,$2)}
| COMMIT COMMIT_TYPE commitType {yy.commit('','',$3,'')} | COMMIT COMMIT_TYPE commitType {yy.commit('','',$3, undefined)}
| COMMIT COMMIT_TAG STR COMMIT_TYPE commitType {yy.commit('','',$5,$3)} | COMMIT commitTags COMMIT_TYPE commitType {yy.commit('','',$4,$2)}
| COMMIT COMMIT_TYPE commitType COMMIT_TAG STR {yy.commit('','',$3,$5)} | COMMIT COMMIT_TYPE commitType commitTags {yy.commit('','',$3,$4)}
| COMMIT COMMIT_ID STR {yy.commit('',$3,yy.commitType.NORMAL,'')} | COMMIT COMMIT_ID STR {yy.commit('',$3,yy.commitType.NORMAL, undefined)}
| COMMIT COMMIT_ID STR COMMIT_TAG STR {yy.commit('',$3,yy.commitType.NORMAL,$5)} | COMMIT COMMIT_ID STR commitTags {yy.commit('',$3,yy.commitType.NORMAL,$4)}
| COMMIT COMMIT_TAG STR COMMIT_ID STR {yy.commit('',$5,yy.commitType.NORMAL,$3)} | COMMIT commitTags COMMIT_ID STR {yy.commit('',$4,yy.commitType.NORMAL,$2)}
| COMMIT COMMIT_ID STR COMMIT_TYPE commitType {yy.commit('',$3,$5,'')} | COMMIT COMMIT_ID STR COMMIT_TYPE commitType {yy.commit('',$3,$5, undefined)}
| COMMIT COMMIT_TYPE commitType COMMIT_ID STR {yy.commit('',$5,$3,'')} | COMMIT COMMIT_TYPE commitType COMMIT_ID STR {yy.commit('',$5,$3, undefined)}
| COMMIT COMMIT_ID STR COMMIT_TYPE commitType COMMIT_TAG STR {yy.commit('',$3,$5,$7)} | COMMIT COMMIT_ID STR COMMIT_TYPE commitType commitTags {yy.commit('',$3,$5,$6)}
| COMMIT COMMIT_ID STR COMMIT_TAG STR COMMIT_TYPE commitType {yy.commit('',$3,$7,$5)} | COMMIT COMMIT_ID STR commitTags COMMIT_TYPE commitType {yy.commit('',$3,$6,$4)}
| COMMIT COMMIT_TYPE commitType COMMIT_ID STR COMMIT_TAG STR {yy.commit('',$5,$3,$7)} | COMMIT COMMIT_TYPE commitType COMMIT_ID STR commitTags {yy.commit('',$5,$3,$6)}
| COMMIT COMMIT_TYPE commitType COMMIT_TAG STR COMMIT_ID STR {yy.commit('',$7,$3,$5)} | COMMIT COMMIT_TYPE commitType commitTags COMMIT_ID STR {yy.commit('',$6,$3,$4)}
| COMMIT COMMIT_TAG STR COMMIT_TYPE commitType COMMIT_ID STR {yy.commit('',$7,$5,$3)} | COMMIT commitTags COMMIT_TYPE commitType COMMIT_ID STR {yy.commit('',$6,$4,$2)}
| COMMIT COMMIT_TAG STR COMMIT_ID STR COMMIT_TYPE commitType {yy.commit('',$5,$7,$3)} | COMMIT commitTags COMMIT_ID STR COMMIT_TYPE commitType {yy.commit('',$4,$6,$2)}
| COMMIT COMMIT_MSG STR {yy.commit($3,'',yy.commitType.NORMAL,'')} | COMMIT COMMIT_MSG STR {yy.commit($3,'',yy.commitType.NORMAL, undefined)}
| COMMIT COMMIT_TAG STR COMMIT_MSG STR {yy.commit($5,'',yy.commitType.NORMAL,$3)} | COMMIT commitTags COMMIT_MSG STR {yy.commit($4,'',yy.commitType.NORMAL,$2)}
| COMMIT COMMIT_MSG STR COMMIT_TAG STR {yy.commit($3,'',yy.commitType.NORMAL,$5)} | COMMIT COMMIT_MSG STR commitTags {yy.commit($3,'',yy.commitType.NORMAL,$4)}
| COMMIT COMMIT_MSG STR COMMIT_TYPE commitType {yy.commit($3,'',$5,'')} | COMMIT COMMIT_MSG STR COMMIT_TYPE commitType {yy.commit($3,'',$5, undefined)}
| COMMIT COMMIT_TYPE commitType COMMIT_MSG STR {yy.commit($5,'',$3,'')} | COMMIT COMMIT_TYPE commitType COMMIT_MSG STR {yy.commit($5,'',$3, undefined)}
| COMMIT COMMIT_ID STR COMMIT_MSG STR {yy.commit($5,$3,yy.commitType.NORMAL,'')} | COMMIT COMMIT_ID STR COMMIT_MSG STR {yy.commit($5,$3,yy.commitType.NORMAL, undefined)}
| COMMIT COMMIT_MSG STR COMMIT_ID STR {yy.commit($3,$5,yy.commitType.NORMAL,'')} | COMMIT COMMIT_MSG STR COMMIT_ID STR {yy.commit($3,$5,yy.commitType.NORMAL, undefined)}
| COMMIT COMMIT_MSG STR COMMIT_TYPE commitType COMMIT_TAG STR {yy.commit($3,'',$5,$7)} | COMMIT COMMIT_MSG STR COMMIT_TYPE commitType commitTags {yy.commit($3,'',$5,$6)}
| COMMIT COMMIT_MSG STR COMMIT_TAG STR COMMIT_TYPE commitType {yy.commit($3,'',$7,$5)} | COMMIT COMMIT_MSG STR commitTags COMMIT_TYPE commitType {yy.commit($3,'',$6,$4)}
| COMMIT COMMIT_TYPE commitType COMMIT_MSG STR COMMIT_TAG STR {yy.commit($5,'',$3,$7)} | COMMIT COMMIT_TYPE commitType COMMIT_MSG STR commitTags {yy.commit($5,'',$3,$6)}
| COMMIT COMMIT_TYPE commitType COMMIT_TAG STR COMMIT_MSG STR {yy.commit($7,'',$3,$5)} | COMMIT COMMIT_TYPE commitType commitTags COMMIT_MSG STR {yy.commit($6,'',$3,$4)}
| COMMIT COMMIT_TAG STR COMMIT_TYPE commitType COMMIT_MSG STR {yy.commit($7,'',$5,$3)} | COMMIT commitTags COMMIT_TYPE commitType COMMIT_MSG STR {yy.commit($6,'',$4,$2)}
| COMMIT COMMIT_TAG STR COMMIT_MSG STR COMMIT_TYPE commitType {yy.commit($5,'',$7,$3)} | COMMIT commitTags COMMIT_MSG STR COMMIT_TYPE commitType {yy.commit($4,'',$6,$2)}
| COMMIT COMMIT_MSG STR COMMIT_TYPE commitType COMMIT_ID STR {yy.commit($3,$7,$5,'')} | COMMIT COMMIT_MSG STR COMMIT_TYPE commitType COMMIT_ID STR {yy.commit($3,$7,$5, undefined)}
| COMMIT COMMIT_MSG STR COMMIT_ID STR COMMIT_TYPE commitType {yy.commit($3,$5,$7,'')} | COMMIT COMMIT_MSG STR COMMIT_ID STR COMMIT_TYPE commitType {yy.commit($3,$5,$7, undefined)}
| COMMIT COMMIT_TYPE commitType COMMIT_MSG STR COMMIT_ID STR {yy.commit($5,$7,$3,'')} | COMMIT COMMIT_TYPE commitType COMMIT_MSG STR COMMIT_ID STR {yy.commit($5,$7,$3, undefined)}
| COMMIT COMMIT_TYPE commitType COMMIT_ID STR COMMIT_MSG STR {yy.commit($7,$5,$3,'')} | COMMIT COMMIT_TYPE commitType COMMIT_ID STR COMMIT_MSG STR {yy.commit($7,$5,$3, undefined)}
| COMMIT COMMIT_ID STR COMMIT_TYPE commitType COMMIT_MSG STR {yy.commit($7,$3,$5,'')} | COMMIT COMMIT_ID STR COMMIT_TYPE commitType COMMIT_MSG STR {yy.commit($7,$3,$5, undefined)}
| COMMIT COMMIT_ID STR COMMIT_MSG STR COMMIT_TYPE commitType {yy.commit($5,$3,$7,'')} | COMMIT COMMIT_ID STR COMMIT_MSG STR COMMIT_TYPE commitType {yy.commit($5,$3,$7, undefined)}
| COMMIT COMMIT_MSG STR COMMIT_TAG STR COMMIT_ID STR {yy.commit($3,$7,yy.commitType.NORMAL,$5)} | COMMIT COMMIT_MSG STR commitTags COMMIT_ID STR {yy.commit($3,$6,yy.commitType.NORMAL,$4)}
| COMMIT COMMIT_MSG STR COMMIT_ID STR COMMIT_TAG STR {yy.commit($3,$5,yy.commitType.NORMAL,$7)} | COMMIT COMMIT_MSG STR COMMIT_ID STR commitTags {yy.commit($3,$5,yy.commitType.NORMAL,$6)}
| COMMIT COMMIT_TAG STR COMMIT_MSG STR COMMIT_ID STR {yy.commit($5,$7,yy.commitType.NORMAL,$3)} | COMMIT commitTags COMMIT_MSG STR COMMIT_ID STR {yy.commit($4,$6,yy.commitType.NORMAL,$2)}
| COMMIT COMMIT_TAG STR COMMIT_ID STR COMMIT_MSG STR {yy.commit($7,$5,yy.commitType.NORMAL,$3)} | COMMIT commitTags COMMIT_ID STR COMMIT_MSG STR {yy.commit($6,$4,yy.commitType.NORMAL,$2)}
| COMMIT COMMIT_ID STR COMMIT_TAG STR COMMIT_MSG STR {yy.commit($7,$3,yy.commitType.NORMAL,$5)} | COMMIT COMMIT_ID STR commitTags COMMIT_MSG STR {yy.commit($6,$3,yy.commitType.NORMAL,$4)}
| COMMIT COMMIT_ID STR COMMIT_MSG STR COMMIT_TAG STR {yy.commit($5,$3,yy.commitType.NORMAL,$7)} | COMMIT COMMIT_ID STR COMMIT_MSG STR commitTags {yy.commit($5,$3,yy.commitType.NORMAL,$6)}
| COMMIT COMMIT_MSG STR COMMIT_ID STR COMMIT_TYPE commitType COMMIT_TAG STR {yy.commit($3,$5,$7,$9)} | COMMIT COMMIT_MSG STR COMMIT_ID STR COMMIT_TYPE commitType commitTags {yy.commit($3,$5,$7,$8)}
| COMMIT COMMIT_MSG STR COMMIT_ID STR COMMIT_TAG STR COMMIT_TYPE commitType {yy.commit($3,$5,$9,$7)} | COMMIT COMMIT_MSG STR COMMIT_ID STR commitTags COMMIT_TYPE commitType {yy.commit($3,$5,$8,$6)}
| COMMIT COMMIT_MSG STR COMMIT_TYPE commitType COMMIT_ID STR COMMIT_TAG STR {yy.commit($3,$7,$5,$9)} | COMMIT COMMIT_MSG STR COMMIT_TYPE commitType COMMIT_ID STR commitTags {yy.commit($3,$7,$5,$8)}
| COMMIT COMMIT_MSG STR COMMIT_TYPE commitType COMMIT_TAG STR COMMIT_ID STR {yy.commit($3,$9,$5,$7)} | COMMIT COMMIT_MSG STR COMMIT_TYPE commitType commitTags COMMIT_ID STR {yy.commit($3,$8,$5,$6)}
| COMMIT COMMIT_MSG STR COMMIT_TAG STR COMMIT_ID STR COMMIT_TYPE commitType {yy.commit($3,$7,$9,$5)} | COMMIT COMMIT_MSG STR commitTags COMMIT_ID STR COMMIT_TYPE commitType {yy.commit($3,$6,$8,$4)}
| COMMIT COMMIT_MSG STR COMMIT_TAG STR COMMIT_TYPE commitType COMMIT_ID STR {yy.commit($3,$9,$7,$5)} | COMMIT COMMIT_MSG STR commitTags COMMIT_TYPE commitType COMMIT_ID STR {yy.commit($3,$8,$6,$4)}
| COMMIT COMMIT_ID STR COMMIT_MSG STR COMMIT_TYPE commitType COMMIT_TAG STR {yy.commit($5,$3,$7,$9)} | COMMIT COMMIT_ID STR COMMIT_MSG STR COMMIT_TYPE commitType commitTags {yy.commit($5,$3,$7,$8)}
| COMMIT COMMIT_ID STR COMMIT_MSG STR COMMIT_TAG STR COMMIT_TYPE commitType {yy.commit($5,$3,$9,$7)} | COMMIT COMMIT_ID STR COMMIT_MSG STR commitTags COMMIT_TYPE commitType {yy.commit($5,$3,$8,$6)}
| COMMIT COMMIT_ID STR COMMIT_TYPE commitType COMMIT_MSG STR COMMIT_TAG STR {yy.commit($7,$3,$5,$9)} | COMMIT COMMIT_ID STR COMMIT_TYPE commitType COMMIT_MSG STR commitTags {yy.commit($7,$3,$5,$8)}
| COMMIT COMMIT_ID STR COMMIT_TYPE commitType COMMIT_TAG STR COMMIT_MSG STR {yy.commit($9,$3,$5,$7)} | COMMIT COMMIT_ID STR COMMIT_TYPE commitType commitTags COMMIT_MSG STR {yy.commit($8,$3,$5,$6)}
| COMMIT COMMIT_ID STR COMMIT_TAG STR COMMIT_MSG STR COMMIT_TYPE commitType {yy.commit($7,$3,$9,$5)} | COMMIT COMMIT_ID STR commitTags COMMIT_MSG STR COMMIT_TYPE commitType {yy.commit($6,$3,$8,$4)}
| COMMIT COMMIT_ID STR COMMIT_TAG STR COMMIT_TYPE commitType COMMIT_MSG STR {yy.commit($9,$3,$7,$5)} | COMMIT COMMIT_ID STR commitTags COMMIT_TYPE commitType COMMIT_MSG STR {yy.commit($8,$3,$6,$4)}
| COMMIT COMMIT_TAG STR COMMIT_ID STR COMMIT_TYPE commitType COMMIT_MSG STR {yy.commit($9,$5,$7,$3)} | COMMIT commitTags COMMIT_ID STR COMMIT_TYPE commitType COMMIT_MSG STR {yy.commit($8,$4,$6,$2)}
| COMMIT COMMIT_TAG STR COMMIT_ID STR COMMIT_MSG STR COMMIT_TYPE commitType {yy.commit($7,$5,$9,$3)} | COMMIT commitTags COMMIT_ID STR COMMIT_MSG STR COMMIT_TYPE commitType {yy.commit($6,$4,$8,$2)}
| COMMIT COMMIT_TAG STR COMMIT_TYPE commitType COMMIT_ID STR COMMIT_MSG STR {yy.commit($9,$7,$5,$3)} | COMMIT commitTags COMMIT_TYPE commitType COMMIT_ID STR COMMIT_MSG STR {yy.commit($8,$6,$4,$2)}
| COMMIT COMMIT_TAG STR COMMIT_TYPE commitType COMMIT_MSG STR COMMIT_ID STR {yy.commit($7,$9,$5,$3)} | COMMIT commitTags COMMIT_TYPE commitType COMMIT_MSG STR COMMIT_ID STR {yy.commit($6,$8,$4,$2)}
| COMMIT COMMIT_TAG STR COMMIT_MSG STR COMMIT_ID STR COMMIT_TYPE commitType {yy.commit($5,$7,$9,$3)} | COMMIT commitTags COMMIT_MSG STR COMMIT_ID STR COMMIT_TYPE commitType {yy.commit($4,$6,$8,$2)}
| COMMIT COMMIT_TAG STR COMMIT_MSG STR COMMIT_TYPE commitType COMMIT_ID STR {yy.commit($5,$9,$7,$3)} | COMMIT commitTags COMMIT_MSG STR COMMIT_TYPE commitType COMMIT_ID STR {yy.commit($4,$8,$6,$2)}
| COMMIT COMMIT_TYPE commitType COMMIT_ID STR COMMIT_MSG STR COMMIT_TAG STR {yy.commit($7,$5,$3,$9)} | COMMIT COMMIT_TYPE commitType COMMIT_ID STR COMMIT_MSG STR commitTags {yy.commit($7,$5,$3,$8)}
| COMMIT COMMIT_TYPE commitType COMMIT_ID STR COMMIT_TAG STR COMMIT_MSG STR {yy.commit($9,$5,$3,$7)} | COMMIT COMMIT_TYPE commitType COMMIT_ID STR commitTags COMMIT_MSG STR {yy.commit($8,$5,$3,$6)}
| COMMIT COMMIT_TYPE commitType COMMIT_TAG STR COMMIT_MSG STR COMMIT_ID STR {yy.commit($7,$9,$3,$5)} | COMMIT COMMIT_TYPE commitType commitTags COMMIT_MSG STR COMMIT_ID STR {yy.commit($6,$8,$3,$4)}
| COMMIT COMMIT_TYPE commitType COMMIT_TAG STR COMMIT_ID STR COMMIT_MSG STR {yy.commit($9,$7,$3,$5)} | COMMIT COMMIT_TYPE commitType commitTags COMMIT_ID STR COMMIT_MSG STR {yy.commit($8,$6,$3,$4)}
| COMMIT COMMIT_TYPE commitType COMMIT_MSG STR COMMIT_ID STR COMMIT_TAG STR {yy.commit($5,$7,$3,$9)} | COMMIT COMMIT_TYPE commitType COMMIT_MSG STR COMMIT_ID STR commitTags {yy.commit($5,$7,$3,$8)}
| COMMIT COMMIT_TYPE commitType COMMIT_MSG STR COMMIT_TAG STR COMMIT_ID STR {yy.commit($5,$9,$3,$7)} | COMMIT COMMIT_TYPE commitType COMMIT_MSG STR commitTags COMMIT_ID STR {yy.commit($5,$8,$3,$6)}
// | COMMIT COMMIT_ID STR {yy.commit('',$3,yy.commitType.NORMAL,'')}
// | COMMIT COMMIT_TYPE commitType {yy.commit('','',$3,'')}
// | COMMIT COMMIT_TAG STR {yy.commit('','',yy.commitType.NORMAL,$3)}
// | COMMIT COMMIT_MSG STR {yy.commit($3,'',yy.commitType.NORMAL,'')}
// | COMMIT COMMIT_TAG STR COMMIT_TYPE commitType {yy.commit('','',$5,$3)}
// | COMMIT COMMIT_TYPE commitType COMMIT_TAG STR {yy.commit('','',$3,$5)}
// | COMMIT COMMIT_ID STR COMMIT_TYPE commitType {yy.commit('',$3,$5,'')}
// | COMMIT COMMIT_ID STR COMMIT_TAG STR {yy.commit('',$3,yy.commitType.NORMAL,$5)}
// | COMMIT COMMIT_ID STR COMMIT_TYPE commitType COMMIT_TAG STR {yy.commit('',$3,$5,$7)}
// | COMMIT COMMIT_ID STR COMMIT_TAG STR COMMIT_TYPE commitType {yy.commit('',$3,$7,$5)}
; ;
commit_arg commit_arg
: /* empty */ {$$ = ""} : /* empty */ {$$ = ""}
@@ -238,6 +221,12 @@ commitType
| REVERSE { $$=yy.commitType.REVERSE;} | REVERSE { $$=yy.commitType.REVERSE;}
| HIGHLIGHT { $$=yy.commitType.HIGHLIGHT;} | HIGHLIGHT { $$=yy.commitType.HIGHLIGHT;}
; ;
commitTags
: COMMIT_TAG STR {$$=[$2]}
| COMMIT_TAG EMPTYSTR {$$=['']}
| commitTags COMMIT_TAG STR {$commitTags.push($3); $$=$commitTags;}
| commitTags COMMIT_TAG EMPTYSTR {$commitTags.push(''); $$=$commitTags;}
;
ref ref
: ID : ID

View File

@@ -19,10 +19,12 @@ pnpm build:esbuild
pnpm build:types pnpm build:types
# Clone the Mermaid Live Editor repository # Clone the Mermaid Live Editor repository
rm -rf mermaid-live-editor if [ ! -d "mermaid-live-editor" ]; then
git clone --single-branch https://github.com/mermaid-js/mermaid-live-editor.git git clone --single-branch https://github.com/mermaid-js/mermaid-live-editor.git
fi
cd mermaid-live-editor cd mermaid-live-editor
git clean -xdf
rm -rf docs/
# We have to use npm instead of yarn because it causes trouble in netlify # We have to use npm instead of yarn because it causes trouble in netlify
# Install dependencies # Install dependencies