mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-11-11 16:24:12 +01:00
Merge pull request #2954 from husa/feature/2936-gitgraph-pathed-branch-name
GitGraph: add support for "pathed" branches. fix #2936
This commit is contained in:
@@ -336,6 +336,20 @@ describe('when parsing a gitGraph', function () {
|
|||||||
expect(Object.keys(parser.yy.getBranches()).length).toBe(2);
|
expect(Object.keys(parser.yy.getBranches()).length).toBe(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should allow _-./ characters in branch names', function () {
|
||||||
|
const str = `gitGraph:
|
||||||
|
commit
|
||||||
|
branch azAZ_-./test
|
||||||
|
`;
|
||||||
|
|
||||||
|
parser.parse(str);
|
||||||
|
const commits = parser.yy.getCommits();
|
||||||
|
expect(Object.keys(commits).length).toBe(1);
|
||||||
|
expect(parser.yy.getCurrentBranch()).toBe('azAZ_-./test');
|
||||||
|
expect(parser.yy.getDirection()).toBe('LR');
|
||||||
|
expect(Object.keys(parser.yy.getBranches()).length).toBe(2);
|
||||||
|
});
|
||||||
|
|
||||||
it('should handle new branch checkout', function () {
|
it('should handle new branch checkout', function () {
|
||||||
const str = `gitGraph:
|
const str = `gitGraph:
|
||||||
commit
|
commit
|
||||||
|
|||||||
@@ -26,31 +26,31 @@
|
|||||||
\s+ /* skip all whitespace */
|
\s+ /* skip all whitespace */
|
||||||
\#[^\n]* /* skip comments */
|
\#[^\n]* /* skip comments */
|
||||||
\%%[^\n]* /* skip comments */
|
\%%[^\n]* /* skip comments */
|
||||||
"gitGraph" return 'GG';
|
"gitGraph" return 'GG';
|
||||||
"commit" return 'COMMIT';
|
"commit" return 'COMMIT';
|
||||||
"id:" return 'COMMIT_ID';
|
"id:" return 'COMMIT_ID';
|
||||||
"type:" return 'COMMIT_TYPE';
|
"type:" return 'COMMIT_TYPE';
|
||||||
"msg:" return 'COMMIT_MSG';
|
"msg:" return 'COMMIT_MSG';
|
||||||
"NORMAL" return 'NORMAL';
|
"NORMAL" return 'NORMAL';
|
||||||
"REVERSE" return 'REVERSE';
|
"REVERSE" return 'REVERSE';
|
||||||
"HIGHLIGHT" return 'HIGHLIGHT';
|
"HIGHLIGHT" return 'HIGHLIGHT';
|
||||||
"tag:" return 'COMMIT_TAG';
|
"tag:" return 'COMMIT_TAG';
|
||||||
"branch" return 'BRANCH';
|
"branch" return 'BRANCH';
|
||||||
"merge" return 'MERGE';
|
"merge" return 'MERGE';
|
||||||
// "reset" return 'RESET';
|
// "reset" return 'RESET';
|
||||||
"checkout" return 'CHECKOUT';
|
"checkout" return 'CHECKOUT';
|
||||||
"LR" return 'DIR';
|
"LR" return 'DIR';
|
||||||
"BT" return 'DIR';
|
"BT" return 'DIR';
|
||||||
":" return ':';
|
":" return ':';
|
||||||
"^" return 'CARET'
|
"^" return 'CARET'
|
||||||
"options"\r?\n this.begin("options");
|
"options"\r?\n this.begin("options");
|
||||||
<options>"end"\r?\n this.popState();
|
<options>"end"\r?\n this.popState();
|
||||||
<options>[^\n]+\r?\n return 'OPT';
|
<options>[^\n]+\r?\n return 'OPT';
|
||||||
["] this.begin("string");
|
["] this.begin("string");
|
||||||
<string>["] this.popState();
|
<string>["] this.popState();
|
||||||
<string>[^"]* return 'STR';
|
<string>[^"]* return 'STR';
|
||||||
[a-zA-Z][-_\.a-zA-Z0-9]*[-_a-zA-Z0-9] return 'ID';
|
[a-zA-Z][-_\./a-zA-Z0-9]*[-_a-zA-Z0-9] return 'ID';
|
||||||
<<EOF>> return 'EOF';
|
<<EOF>> return 'EOF';
|
||||||
|
|
||||||
/lex
|
/lex
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user