Skip to content

Commit

Permalink
GitGraph: Correct commit variable in overlap check.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
guypursey committed Oct 7, 2023
1 parent b3d1929 commit 64c2b9b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/mermaid/src/diagrams/git/gitGraphRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down

0 comments on commit 64c2b9b

Please sign in to comment.