Merge pull request #3392 from aloisklink/fix/3347_support_branch_names_that_start_with_numbers
fix(git): support numeric branch names
This commit is contained in:
commit
97ed63de5a
|
@ -348,6 +348,21 @@ 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 branch names starting with numbers', function () {
|
||||||
|
const str = `gitGraph:
|
||||||
|
commit
|
||||||
|
%% branch names starting with numbers are not recommended, but are supported by git
|
||||||
|
branch 1.0.1
|
||||||
|
`;
|
||||||
|
|
||||||
|
parser.parse(str);
|
||||||
|
const commits = parser.yy.getCommits();
|
||||||
|
expect(Object.keys(commits).length).toBe(1);
|
||||||
|
expect(parser.yy.getCurrentBranch()).toBe('1.0.1');
|
||||||
|
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
|
||||||
|
|
|
@ -33,7 +33,6 @@ accDescr\s*"{"\s* { this.begin("ac
|
||||||
<acc_descr_multiline>[\}] { this.popState(); }
|
<acc_descr_multiline>[\}] { this.popState(); }
|
||||||
<acc_descr_multiline>[^\}]* return "acc_descr_multiline_value";
|
<acc_descr_multiline>[^\}]* return "acc_descr_multiline_value";
|
||||||
(\r?\n)+ /*{console.log('New line');return 'NL';}*/ return 'NL';
|
(\r?\n)+ /*{console.log('New line');return 'NL';}*/ return 'NL';
|
||||||
\s+ /* skip all whitespace */
|
|
||||||
\#[^\n]* /* skip comments */
|
\#[^\n]* /* skip comments */
|
||||||
\%%[^\n]* /* skip comments */
|
\%%[^\n]* /* skip comments */
|
||||||
"gitGraph" return 'GG';
|
"gitGraph" return 'GG';
|
||||||
|
@ -61,9 +60,10 @@ accDescr\s*"{"\s* { this.begin("ac
|
||||||
["] this.begin("string");
|
["] this.begin("string");
|
||||||
<string>["] this.popState();
|
<string>["] this.popState();
|
||||||
<string>[^"]* return 'STR';
|
<string>[^"]* return 'STR';
|
||||||
[0-9]+ return 'NUM';
|
[0-9]+(?=\s|$) return 'NUM';
|
||||||
[a-zA-Z][-_\./a-zA-Z0-9]*[-_a-zA-Z0-9] return 'ID';
|
\w[-\./\w]*[-\w] return 'ID'; // only a subset of https://git-scm.com/docs/git-check-ref-format
|
||||||
<<EOF>> return 'EOF';
|
<<EOF>> return 'EOF';
|
||||||
|
\s+ /* skip all whitespace */ // lowest priority so we can use lookaheads in earlier regex
|
||||||
|
|
||||||
/lex
|
/lex
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue