Skip to content

Commit

Permalink
GitGraph: made reroute fn more readable
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
guypursey committed Oct 27, 2023
1 parent ed911e0 commit 22fd12d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/mermaid/src/diagrams/git/gitGraphRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,8 @@ const drawCommits = (svg, commits, modifyGraph) => {
* return true
*/
const shouldRerouteArrow = (commitA, commitB, p1, p2, allCommits) => {
const branchToGetCurve = (dir === 'TB' ? p1.x < p2.x : p1.y < p2.y)
? commitB.branch
: commitA.branch;
const commitBIsFurthest = dir === 'TB' ? p1.x < p2.x : p1.y < p2.y;
const branchToGetCurve = commitBIsFurthest ? commitB.branch : commitA.branch;
const isOnBranchToGetCurve = (x) => x.branch === branchToGetCurve;
const isBetweenCommits = (x) => x.seq > commitA.seq && x.seq < commitB.seq;
return Object.values(allCommits).some((commitX) => {
Expand Down

0 comments on commit 22fd12d

Please sign in to comment.