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 31, 2023
1 parent a9c5d90 commit 57a9d73
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 57a9d73

Please sign in to comment.