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: Cannot merge main into a production branch that has no prior commits in it #5898

Open
threepistons opened this issue Sep 25, 2024 · 2 comments
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect

Comments

@threepistons
Copy link

threepistons commented Sep 25, 2024

Description

I'm sure that this syntax used to work, because I would not have allowed a broken diagram into my documentation back in January and my diagram is broken now, so I'm raising this as a regression bug.

A common use case for Git is to have a main (or master, or develop) branch that is merged at intervals into a production (or release, or deployment) branch. A simple example of gitGraph to display this would be as follows:

gitGraph
    commit id: "Initial commit, will be released in the production branch about to be created."
    branch production
    merge main
    checkout main
    commit id: "Dave adds a config file"
    branch 01_topic
    checkout 01_topic
    commit id: "Helen adds a feature"
    checkout main
    commit id: "Dave adds another config file"
    commit id: "Tom adds a config file"
    checkout 01_topic
    commit id: "Helen adds more of the feature"
    checkout main
    merge 01_topic id: "Helen merges the feature into main"
    commit id: "Claire adds a config file"
    commit id: "Dave adds yet another config file"
    checkout production
    merge main id: "Helen merges main to production"
Loading

In the development version of the Live Editor and in GitHub, I get "Error: Cannot merge branch 'main' into itself."

What I expect is a diagram that looks something like:
puppet-r10k-flow-for-mermaid-bug-report

Steps to reproduce

  1. Go to https://develop.git.mermaid.live/
  2. Paste the code in the code snippet.
  3. See the error message instead of a diagram.

Or go to https://develop.git.mermaid.live/edit#pako:eNqdU01PwzAM_StWzhWCa69MAg6c4FgJuYnbRiRx5aagadp_x11X2KZtCJpL82y_569sjGVHpjStzw-CfVcl0M9yjD6DdyVU5in57DHswQI-fQhQEwgFwoEc-AS5I-iF3Wiz5wS1YLIdYM1jhsyTtxXCTO6mMrPE3uUnaIYjSUsQUTln9Y5Cv8TYjuz7RDnZz2S6wg8CdG4AVENqfAuND3QieXv3lrn39oTzBD7kfdRK00LcaB2j0D9ySqxtknOZHUW8crxSxB_zjSwE3OwG9Hvmc_cX5iO2nWk45NG562gjDpnkbCH3Ab1cG8iFRq0pX23Wkvfl3an0mMIooDen672ZPCoTuK3MJOaoHvW3mGFVirQ3oLxPQlsNxzHzyzpZU2YZqTDCY9uZssEw6G3snS70ymMrGL9Rcj6zPM-Pave2tl_0yCHc for one I made earlier.

Screenshots

No response

Code Sample

gitGraph
    commit id: "Initial commit, will be released in the production branch about to be created."
    branch production
    merge main
    checkout main
    commit id: "Dave adds a config file"
    branch 01_topic
    checkout 01_topic
    commit id: "Helen adds a feature"
    checkout main
    commit id: "Dave adds another config file"
    commit id: "Tom adds a config file"
    checkout 01_topic
    commit id: "Helen adds more of the feature"
    checkout main
    merge 01_topic id: "Helen merges the feature into main"
    commit id: "Claire adds a config file"
    commit id: "Dave adds yet another config file"
    checkout production
    merge main id: "Helen merges main to production"

Setup

  • Mermaid version: Live develop
  • Browser and Version: This happens in Chromium and Firefox. My Chromium is 128.0.6613.84.

Suggested Solutions

No response

Additional Context

No response

@threepistons threepistons added Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect labels Sep 25, 2024
@threepistons threepistons changed the title Cannot merge main into a production branch that has no prior commits in it gitGraph: Cannot merge main into a production branch that has no prior commits in it Sep 25, 2024
@EBrookeLoreto
Copy link

I've hit this problem too after re-publishing my site.

mermaid.min.js:710  Uncaught (in promise) Error: Cannot merge branch 'master' into itself.
    at Object.merge (mermaid.min.js:710:3360)
    at Merge (mermaid.min.js:710:9334)
    at parseStatement (mermaid.min.js:710:9471)
    at populate (mermaid.min.js:710:9200)
    at Object.parse (mermaid.min.js:710:10035)
    at async Diagram.fromText (mermaid.min.js:2108:248)
    at async Object.render (mermaid.min.js:2146:1187)

This worked previously but I'm not 100% which version of Mermaid I was using. I'm using a MkDocs site.

@rbroth
Copy link

rbroth commented Nov 4, 2024

I'm also affected.

It seems that in previous versions it was possible to merge another branch so that only a merge commit was created, but with this bug it's necessary to create a "normal" commit first.

This used to work:

gitGraph
    commit id: " "
    branch branch2
    checkout main
    commit id: " "
    checkout branch2
    merge main
gitGraph
    commit id: " "
    branch branch2
    checkout main
    commit id: " "
    checkout branch2
    merge main
Loading

Now this is necessary:

gitGraph
    commit id: " "
    branch branch2
    checkout main
    commit id: " "
    checkout branch2
    commit id: "dummy commit"
    merge main
gitGraph
    commit id: " "
    branch branch2
    checkout main
    commit id: " "
    checkout branch2
    commit id: "dummy commit"
    merge main
Loading

Edit: Confirm broken in mermaid version 10.7.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect
Projects
None yet
Development

No branches or pull requests

3 participants