Open guypursey opened 1 year ago
+1 @guypursey
for context, I was trying to write some guidance which is largely aligned to https://learn.microsoft.com/en-us/azure/devops/repos/git/git-branching-guidance?view=azure-devops#use-release-branches and other schemes which advocate release branches and depict them above main
(and obviously never merging into it), whereas feature branches are depicted below main
and generally do merge into it.
@ijmitch Thanks for the extra context. With this in mind, do you think the point I've made about the curves still makes sense?
Guess it's a design decision about whether curves and straight lines are a visual shorthand for anything semantically. I haven't found any guidance or documentation on this in the Mermaid repo so far.
It would be ideal in my opinion if branching 'upwards' was a mirror-image of the normal 'downwards' rendering. So, yes, I mentioned the colour and was a bit lazy not to mention the curves used as well.
Hi @guypursey, are you working on this?
Hi @mathbraga, yes, I started work on this, as I was looking at those parts of the codebase already and drafting documentation. But I'm waiting to see if #4927 will be accepted and merged as I was building on top of the work in that PR.
Yeah I noticed your involvement with #4927, that's why I wanted to know before diving too much into this.
I did dig into this for a bit though, so I'll share some of what I found out that might help.
I believe that one of the ways to solving this would be to identify when a branch is above or below main
.
getBranchesAsObjArray
in /packages/mermaid/src/diagrams/git/gitGraphAst.js
returns only the name of each branch. You can modify this to return also the branch order value.
The second .map
inside getBranchesAsObjArray
could be changed from:
.map(({ name }) => ({ name }))
to something like
.map(({ name, order }) => ({ name, order }))
Then inside draw
in /packages/mermaid/src/diagrams/git/gitGraphRenderer.js
you can have access to branches with ordering. Then you can modify drawArrows
to also accept branches
as input and work from there.
I didn't really give much thought to this so there could be better solutions, just felt like leaving this here as it could help.
Description
Branches render unexpectedly differently when they're positioned above
main
(as compared with their default position underneathmain
).This was found by @ijmitch during proposed fix for #4912.
Steps to reproduce
main
before joiningrelease-1
with a curve."gitGraph": { "mainBranchOrder": 2}
, or b Paste following line above graph code:%%{init: {'theme': 'base', 'gitGraph': {'mainBranchOrder': 2}} }%%
main
branch instead and curves out ofmain
before joiningrelease-1
straight on.Screenshots
Here are examples with simplest possible graph for demonstration.
Example, standard with
main
as top branch:Example, standard with main as bottom branch:
Setup
Suggested Solutions
Amend conditionals around path rendering to take branch position into account, in the same way that top-to-bottom is considered separately from default left-to-right rendering.
Additional Context
Assumption: that branch curves should only apply to branches that aren't
main
.