Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitGraph: allow branch names starting with "branch" #3362

Closed
DanySK opened this issue Aug 26, 2022 · 1 comment · Fixed by #3438
Closed

GitGraph: allow branch names starting with "branch" #3362

DanySK opened this issue Aug 26, 2022 · 1 comment · Fixed by #3438
Labels
Type: Bug / Error Something isn't working or is incorrect

Comments

@DanySK
Copy link

DanySK commented Aug 26, 2022

Describe the bug

Git allows dashes and slashes to be used as branch names.
Currently, mermaid.js renders them in the main branch, but does not allow to checkout or create branches with these valid names.

To Reproduce

see the remainder of the report

Expected behavior

All the following charts work

Screenshots

see code samples

Code Sample
If applicable, add the code sample or a link to the live editor.

Working case

%%{init: { 'gitGraph': { 'mainBranchName': 'branch1'}} }%%
gitGraph
  commit
  commit
  commit
  branch branch2
  commit
  checkout branch1
  commit
  checkout branch2
  commit
%%{init: { 'gitGraph': { 'mainBranchName': 'branch1'}} }%%
gitGraph
  commit
  commit
  commit
  branch branch2
  commit
  checkout branch1
  commit
  checkout branch2
  commit
Loading

New branch name with dash

%%{init: { 'logLevel': 'debug', 'gitGraph': { 'mainBranchName': 'default-branch'}} }%%
gitGraph
  commit
  commit
  commit
  branch branch-2
  commit
  checkout default-branch
  commit
  checkout branch-2
  commit
%%{init: { 'logLevel': 'debug', 'gitGraph': { 'mainBranchName': 'default-branch'}} }%%
gitGraph
  commit
  commit
  commit
  branch branch-2
  commit
  checkout default-branch
  commit
  checkout branch-2
  commit
Loading

New branch name with slash

%%{init: { 'logLevel': 'debug', 'gitGraph': { 'mainBranchName': 'default-branch'}} }%%
gitGraph
  commit
  commit
  commit
  branch branch/b2
  commit
  checkout default-branch
  commit
  checkout branch/b2
  commit
%%{init: { 'logLevel': 'debug', 'gitGraph': { 'mainBranchName': 'default-branch'}} }%%
gitGraph
  commit
  commit
  commit
  branch branch/b2
  commit
  checkout default-branch
  commit
  checkout branch/b2
  commit
Loading
@DanySK DanySK added Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect labels Aug 26, 2022
@aloisklink
Copy link
Member

Hi, dashes and slashes work in Mermaid v9.1.0 or later, thanks to #2954.

However, branch names cannot start with branch (it's a reserved keyword in the parser).

The examples you give work fine, as long as I rename the branch to bran:

New branch name with dash

%%{init: { 'logLevel': 'debug', 'gitGraph': { 'mainBranchName': 'default-branch'}} }%%
gitGraph
  commit
  commit
  commit
  branch branc-2
  commit
  checkout default-branch
  commit
  checkout branc-2
  commit
%%{init: { 'logLevel': 'debug', 'gitGraph': { 'mainBranchName': 'default-branch'}} }%%
gitGraph
  commit
  commit
  commit
  branch branc-b2
  commit
  checkout default-branch
  commit
  checkout branc-b2
  commit
Loading

New branch name with slash

%%{init: { 'logLevel': 'debug', 'gitGraph': { 'mainBranchName': 'default-branch'}} }%%
gitGraph
  commit
  commit
  commit
  branch branc/b2
  commit
  checkout default-branch
  commit
  checkout branc/b2
  commit
%%{init: { 'logLevel': 'debug', 'gitGraph': { 'mainBranchName': 'default-branch'}} }%%
gitGraph
  commit
  commit
  commit
  branch branc/b2
  commit
  checkout default-branch
  commit
  checkout branc/b2
  commit
Loading

@knsv knsv removed the Status: Triage Needs to be verified, categorized, etc label Sep 2, 2022
@aloisklink aloisklink changed the title GitGraph: allow dashes and slashes in branch names GitGraph: allow branch names starting with "branch" Sep 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug / Error Something isn't working or is incorrect
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants