-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Bug/4912 GitGraph routing and colouring for merges and cherry-picks #4927
Bug/4912 GitGraph routing and colouring for merges and cherry-picks #4927
Conversation
✅ Deploy Preview for mermaid-js ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## develop #4927 +/- ##
===========================================
- Coverage 80.13% 79.37% -0.77%
===========================================
Files 164 164
Lines 13864 13869 +5
Branches 698 698
===========================================
- Hits 11110 11008 -102
- Misses 2604 2711 +107
Partials 150 150
Flags with carried forward coverage won't be shown. Click here to find out more.
|
c4843e0
to
2a564f0
Compare
E2E tests passing locally but just one test is failing remotely ( Took the opportunity to reword some commit messages via rebase interactive and force pushed changes to retrigger test run. |
2a564f0
to
d601a88
Compare
@nirname Not sure of etiquette re requesting approval but this one is ready for review now 🙂 |
@guypursey No problem at all, ask for review as many times as needed. I saw you have added demo page. That is good, but not enough. We also need to ensure that the following changes won't break this one. Code Coverage complains about that line you've added. Perhaps you need to add another end-2-end test on top of the existing ones. Integration tests basically make a screenshot and compare it when you do the changes. A couple of samples to cover both |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also need to check this solution against TB graph
8e1de27
to
14d585e
Compare
@nirname @mathbraga I have made a few changes since your last reviews and updated the PR description at the top. It looks like code coverage has now increased slightly from the |
Hey @guypursey, all looks good for my reviews. I think only @nirname can resolve conversations though. |
@nirname Good catch.
Ready for review 👍 |
@guypursey You missed the |
Ah, thanks @mathbraga. Well spotted. I've updated that now. In looking again, I realised I hadn't specified the commit IDs in each new test. This meant the IDs would show up in diff output as they would change between Cypress runs. So I've now followed the practice of other graphs and added an ID for each commit 👍 |
7922dc9
to
39ae754
Compare
@nirname I've just rebased this PR from I think I've addressed your request now, so ready for review again when you have time 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@guypursey Sorry for long response. I have discovered that unnecessary routing still appears in your branch, while it does not appear in current release
Expected behaviour (and current release behavior)
Current behaviour (in this branch only)
I know it seems to be minor, nevertheless users rely on the layout, and if it changes suddenly their docs may be ruined. We have measure thrice. Try this code to reproduce:
gitGraph:
commit
branch x
checkout main
commit
checkout x
commit
checkout main
merge x
Colors works as expected, by the way. I am not sure why it changes layout. May be this happens because you have changed shouldRerouteArrow
function (formerly hasOverlappingCommits
).
Try investigating it further.
We are almost there. Good to go after fixing some layout problems. Great job. |
39ae754
to
a8e544f
Compare
In these tests, a new branch is created but then a commit is made on the main branch before the new branch gets a commit. This important to see what happens with rerouting of arrows. Suggested by @nirname in PR review of mermaid-js#4927.
In these tests, a new branch is created but then a commit is made on the main branch before the new branch gets a commit. This important to see what happens with rerouting of arrows. Suggested by @nirname in PR review of mermaid-js#4927.
abd00b4
to
dc2fa29
Compare
On previous rewrite, I had created new functions within the overlapping functions but these were being recreated on each iteration of Object.some(). I moved them outside this for clarity and so they're not recreated each iteration.
The function also now does an additional check to see if source branch in overlap check is on main. As we're no longer purely checking for an overlap and the only use of this function is to reroute the arrows to avoid running over commits, this more literal name should be clearer.
Checking if branch was same as main turned out to be redundant for now, since there don't seem to be any cases where routing curves into main. This fixes issue found in review by @nirname and avoids a situation where branching from the same commit results in unnecessary rerouting.
Fix for error spotted by @mathbraga
Followed practice of other tests so that commit IDs are stabilised (i.e., not randomly generated) and therefore don't show repeatedly in Cypress diff output screenshots
In these tests, a new branch is created but then a commit is made on the main branch before the new branch gets a commit. This important to see what happens with rerouting of arrows. Suggested by @nirname in PR review of mermaid-js#4927.
Hypothesised that working out which branch needed checking for overlapping commits might be missing, so added that as a nested ternary and passed result as new argument to rerouting check. If commits are found on the branch which will be getting the curve (whichever branch is lower or more to the right of main than the other, for now), then the arrow will be rerouted. I may refactor in a follow-up commit and I think there's scope to simplify the logic but this is a test for now.
My focus earlier on had been on relationship to `main` branch so this is to ensure that we have some tests that cover relationship between a pair of branches that doesn't include `main`.
Based on review by @nirname. I had originally been trying to minimise number of new arguments being passed to rerouting check but as the branch curve check is not used elsewhere and is part of the same rerouting check it makes sense for them to be together. Position information now passed to rerouting fn instead.
Should stop randomised commit IDs from showing arbitrary differences between test runs.
Wanted to avoid repetition given that the originally nested ternaries had the same structure
Pre-commit lint hook had made the use of ternaries harder to read than I'd originally intended so I introduced an additional variable which explains what is being checked and keeps ternaries from becoming obscured.
22fd12d
to
57a9d73
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@guypursey PR looks wonderful!
@nirname can you resolve the conversations if you're satisfied with the responses?
📑 Summary
Fixes issues with colouring and routing of merges in GitGraph.
Resolves #4912
📏 Design Decisions
commit1
andcommit2
tocommitA
andcommitB
respectively, to prevent confusion withseq
property values (which are also numbers and used to ID the commits).hasOverlappingCommits
function to be easier to read and renamed itshouldRerouteArrow
:Array.some()
instead ofArray.filter()
(should increase performance with larger graphs, if needed)Object.keys()
forObject.values()
📋 Tasks
Make sure you
MERMAID_RELEASE_VERSION
is used for all new features.develop
branch