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 * and commitB's x-position
*/ */
const hasOverlappingCommits = (commitA, commitB, allCommits) => const hasOverlappingCommits = (commitA, commitB, allCommits) =>
Object.values(allCommits).some( Object.values(allCommits).some((commitX) => {
(commitX) => const isOnSourceBranch = (x) => x.branch === commitA.branch;
(commitX.branch === commitA.branch || commitX.branch === commitB.branch) && const isOnTargetBranch = (x) => x.branch === commitB.branch;
commitX.seq > commitA.seq && const isBetweenCommits = (x) => x.seq > commitA.seq && x.seq < commitB.seq;
commitX.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 * This function find a lane in the y-axis that is not overlapping with any other lanes. This is