GitGraph: Rewrote overlap fn to make main branch exception to rule.

This commit is contained in:
Guy Pursey
2023-10-12 21:36:17 +01:00
parent 8c43d2273f
commit 9f8457d249

View File

@@ -352,12 +352,16 @@ const drawCommits = (svg, commits, modifyGraph) => {
* and commitB's x-position
*/
const hasOverlappingCommits = (commitA, commitB, allCommits) =>
Object.values(allCommits).some(
(commitX) =>
(commitX.branch === commitA.branch || commitX.branch === commitB.branch) &&
commitX.seq > commitA.seq &&
commitX.seq < commitB.seq
);
Object.values(allCommits).some((commitX) => {
const isOnSourceBranch = (x) => x.branch === commitA.branch;
const isOnTargetBranch = (x) => x.branch === commitB.branch;
const isBetweenCommits = (x) => x.seq > commitA.seq && x.seq < commitB.seq;
const isTargetMain = (x) => x.branch === getConfig().gitGraph.mainBranchName;
return (
(isOnSourceBranch(commitX) || (isOnTargetBranch(commitX) && !isTargetMain(commitX))) &&
isBetweenCommits(commitX)
);
});
/**
* This function find a lane in the y-axis that is not overlapping with any other lanes. This is