Include logic for gitgraph with unconnected branches

This commit is contained in:
Matheus B 2024-01-16 20:54:26 -03:00
parent 02246f64d2
commit c77a6e156c

View File

@ -115,10 +115,17 @@ const drawCommits = (svg, commits, modifyGraph) => {
sortedKeys.forEach((key) => { sortedKeys.forEach((key) => {
const commit = commits[key]; const commit = commits[key];
if (isParallelCommits && commit.parents.length) { if (isParallelCommits) {
if (!commit.parents.length) {
pos = 0;
if (dir === 'TB') {
pos = 30;
}
} else {
const closestParent = findClosestParent(commit.parents); const closestParent = findClosestParent(commit.parents);
pos = dir === 'TB' ? commitPos[closestParent].y + 40 : commitPos[closestParent].x + 40; pos = dir === 'TB' ? commitPos[closestParent].y + 40 : commitPos[closestParent].x + 40;
} }
}
const y = dir === 'TB' ? pos + 10 : branchPos[commit.branch].pos; const y = dir === 'TB' ? pos + 10 : branchPos[commit.branch].pos;
const x = dir === 'TB' ? branchPos[commit.branch].pos : pos + 10; const x = dir === 'TB' ? branchPos[commit.branch].pos : pos + 10;