GitGraph: simplified overlapping check fn

This commit is contained in:
Guy Pursey
2023-10-13 09:29:43 +01:00
parent 902a9dd42b
commit dba7197fc6

View File

@@ -353,14 +353,10 @@ const drawCommits = (svg, commits, modifyGraph) => {
*/ */
const hasOverlappingCommits = (commitA, commitB, allCommits) => { const hasOverlappingCommits = (commitA, commitB, allCommits) => {
const isOnSourceBranch = (x) => x.branch === commitA.branch; 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 isBetweenCommits = (x) => x.seq > commitA.seq && x.seq < commitB.seq;
const isTargetMain = (x) => x.branch === getConfig().gitGraph.mainBranchName; const sourceIsMain = commitA.branch === getConfig().gitGraph.mainBranchName;
return Object.values(allCommits).some((commitX) => { return Object.values(allCommits).some((commitX) => {
return ( return isBetweenCommits(commitX) && (sourceIsMain || isOnSourceBranch(commitX));
(isOnSourceBranch(commitX) || (isOnTargetBranch(commitX) && !isTargetMain(commitX))) &&
isBetweenCommits(commitX)
);
}); });
}; };