mermaid-js / mermaid

Generation of diagrams like flowcharts or sequence diagrams from text in a similar manner as markdown
https://mermaid.js.org
MIT License
69.02k stars 6.11k forks source link

GitGraph support for commit messages #4908

Open guypursey opened 9 months ago

guypursey commented 9 months ago

Proposal

Ability to add commit messages to commits in a GitGraph.

It's already possible for commits in a GitGraph to be augmented with a custom ID, a type, and a tag.

Users might use the custom ID field to act as a commit message instead. However, although it's not officially documented, there is a tacit assumption that commit IDs in the graph should be unique, else commands like cherry-pick do not work.

Commit messages sometimes need to duplicated. IDs in the graph should be unique, but messages should not.

This was picked up in conversation on issue #4838 where duplication of an ID acting as a message caused an error in the rendering of the graph.

(NB. A similar issue exists but I think it's different: issue #3900 asks for annotations. But this would be more like comments overlaid on top of any aspect of the graph, whether they be commits, branch lines, and merge or cherry-pick arrows. This issue is a syntax request for messages directly integrated into the graph.)

Example

By itself:

gitGraph
    commit message: "Commit message"

With custom ID:

gitGraph
    commit id: "A" message: "Commit message"

With custom IDs, tags, and types:

gitGraph
       commit message: "Initial commit"
       commit id: "Normal" tag: "v1.0.0" message: "First major version"
       commit message: "Incremental changes"
       commit id: "Reverse" type: REVERSE tag: "RC_1" message: "Some changes were reverted here"
       commit message: "Incremental changes"
       commit id: "Highlight" type: HIGHLIGHT tag: "8.8.4" message: "Important changes happened here"

Screenshots

A rough idea of what this could look like:

image

Suggestions:

mr-loop-1 commented 9 months ago

Hi @guypursey , I would like to work on this when it gets through Triage.