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 rendering breaks chronology #4838

Open
moedn opened this issue Sep 14, 2023 · 5 comments
Open

gitGraph rendering breaks chronology #4838

moedn opened this issue Sep 14, 2023 · 5 comments
Labels
Good first issue! Graph: Git Status: Approved Is ready to be worked on Type: Bug / Error Something isn't working or is incorrect

Comments

@moedn
Copy link

moedn commented Sep 14, 2023

Description

First of all: thanks for this amazing project! I use mermaid a lot :)

I'm trying to visualize the branch management for an open source MRI project, but the rendering has a glitch after a certain point (see code samples below)

Steps to reproduce

  1. use the code sample before break from below
  2. everything looks good
  3. use the complete code sample
  4. BUG: the commit working on MDR in FORK-v1.0-MDR comes before minor design changes for MDR in v1-rc, but appears after the merge in the rendered image

Screenshots

before break:

image

complete:

image

Code Sample

complete code sample:


gitGraph
   commit id:"initial commit"
   commit id:"work on first release"
   commit id:"design freeze from here"
   branch v1-rc
   checkout v1-rc
   commit id:"bugfix 1"
   commit id:"bigfix 2" tag:"v1.0.1"
   branch FORK-v1.0-MDR
   checkout FORK-v1.0-MDR
   commit id:"working on MDR"
   checkout v1-rc
   commit id:"minor design changes for MDR" tag:"v1.0.2"
   checkout FORK-v1.0-MDR
   merge v1-rc
   checkout main
   commit id:"new feature for v1.1…"
   checkout FORK-v1.0-MDR
   commit id:"working on MDR"
   commit id:"finishing MDR"
   branch v1.0-MDR
   checkout v1.0-MDR
   commit id:"brush up release" tag:"v1.0.2-MDR"
   checkout v1-rc
   commit id:"bugfix without MDR"
   checkout main
   commit id:"work on v1.1"


code sample until break

```mermaid
gitGraph
   commit id:"initial commit"
   commit id:"work on first release"
   commit id:"design freeze from here"
   branch v1-rc
   checkout v1-rc
   commit id:"bugfix 1"
   commit id:"bigfix 2" tag:"v1.0.1"
   branch FORK-v1.0-MDR
   checkout FORK-v1.0-MDR
   commit id:"working on MDR"
   checkout v1-rc
   commit id:"minor design changes for MDR" tag:"v1.0.2"
   checkout FORK-v1.0-MDR
   merge v1-rc
   checkout main
   commit id:"new feature for v1.1…"


### Setup

- Mermaid version: `10.3.1`
- Browser and Version: Brave v1.57.62 Chromium: 116.0.5845.180 (Official Build) (64-bit) (but rendered in GitLab.com [here](https://gitlab.com/osii/admin/-/issues/1#note_1553323117))

@moedn moedn added Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect labels Sep 14, 2023
@sidharthv96 sidharthv96 added Status: Approved Is ready to be worked on Good first issue! Graph: Git and removed Status: Triage Needs to be verified, categorized, etc labels Sep 15, 2023
@SavvyShah
Copy link

I was just taking a look here and I found that commit id "working on MDR" is repeated. Should this be considered a bug then?

@moedn
Copy link
Author

moedn commented Sep 17, 2023

jepp, that seems to be the issue 👍

if I replace the ID with "further work on MDR", it renders correctly. otherwise mermaid doesn't seem to have an issue with repetitive commit IDs

@Adithya31101
Copy link

I have used mermaid, but never really looked into the code base. But I have experience with D3 and SVGs in general. Can I pick this up, and give it a try?

PS: this is my first shot at open source contribution

@guypursey
Copy link
Contributor

guypursey commented Oct 2, 2023

Is this actually the bug that needs addressing? Or is it more that Mermaid should have an issue with repeated/duplication commit IDs?

Commit IDs should be unique generally, of course. But I think the "cherry-pick" feature in Mermaid would mean the IDs need to be unique for that feature to work.

With unique IDs:

gitGraph
    commit
    branch develop
    checkout develop
    commit id:"hello"
    commit id:"world"
    checkout main
    commit
    cherry-pick id:"hello"
gitGraph
    commit
    branch develop
    checkout develop
    commit id:"hello"
    commit id:"world"
    checkout main
    commit
    cherry-pick id:"hello"
Loading

With duplicate IDs:

gitGraph
    commit
    branch develop
    checkout develop
    commit id:"hello"
    commit id:"hello"
    checkout main
    commit
    cherry-pick id:"hello"

[NOTE: 2 commits now become 1]

gitGraph
    commit
    branch develop
    checkout develop
    commit id:"hello"
    commit id:"hello"
    checkout main
    commit
    cherry-pick id:"hello"
Loading

@guypursey
Copy link
Contributor

Perhaps there's a feature request underlying this -- to have a commit "message:" parameter in the syntax too, which can be duplicated, while IDs remain unique

@jgreywolf jgreywolf added roadmap items to add to roadmap for auto workflow and removed roadmap items to add to roadmap for auto workflow labels Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good first issue! Graph: Git Status: Approved Is ready to be worked on Type: Bug / Error Something isn't working or is incorrect
Projects
None yet
Development

No branches or pull requests

6 participants