GitGraph: Correct commit variable in overlap check.

Originally, the function was checking if any commits were on the
same branch as `commit2`, the destination commit.

However, in order to avoid a conflict, we should only need to
check whether any commits are on the same branch as `commit 1`.

Updated and moved commenting as well.
This commit is contained in:
Guy Pursey
2023-10-07 18:15:29 +01:00
parent f42cec282a
commit d9daf19055

View File

@@ -347,11 +347,13 @@ const drawCommits = (svg, commits, modifyGraph) => {
* @returns {boolean} If there are commits between commit1's x-position and commit2's x-position
*/
const hasOverlappingCommits = (commit1, commit2, allCommits) => {
// Find commits on the same branch as commit2
const keys = Object.keys(allCommits);
const overlappingComits = keys.filter((key) => {
return (
allCommits[key].branch === commit2.branch &&
// Find commits on the same branch as commit1,
// after commit1 but before commit2
// to avoid collision
allCommits[key].branch === commit1.branch &&
allCommits[key].seq > commit1.seq &&
allCommits[key].seq < commit2.seq
);