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:
Ashish Jain
2022-04-21 20:11:39 +02:00
committed by GitHub
2 changed files with 39 additions and 25 deletions

View File

@@ -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

View File

@@ -49,7 +49,7 @@
["] 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