Skip to content

Commit

Permalink
Fix graph lines for commits with >2 children (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
taneliang authored Aug 16, 2020
1 parent 43b010a commit 06b8c6f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/cli/useInteractionReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,19 @@ function backendCommitGraphToDisplayCommits(
a.timestamp > b.timestamp ? 1 : -1,
);
const childDisplayCommits = sortedChildren.flatMap((child, index) => {
const forkIndex = sortedChildren.length - index - 1;
// Last child appears linearly with its parent; every other child forks
// from the main line. Example:
// * Child 2
// | * Child 1
// |/
// | * Child 0
// |/
// * Parent
const hasFork = index !== sortedChildren.length - 1;
return displayCommitsForSubgraphRootedAtCommit(
child,
depth + forkIndex,
forkIndex !== 0,
depth + (hasFork ? 1 : 0),
hasFork,
);
});

Expand Down

0 comments on commit 06b8c6f

Please sign in to comment.