Skip to content
This repository was archived by the owner on Jul 13, 2024. It is now read-only.

Commit b9cfca2

Browse files
authored
Merge pull request #171 from yodalee/fix-wrong-arrow-angle-on-branch-issue159
fix wrong arrow angle on branching
2 parents 034818b + 282a672 commit b9cfca2

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/gitgraph.js

+11-6
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,17 @@
673673
this.template.commit.color ||
674674
this.template.colors[columnIndex];
675675
options.parent = this.parent;
676-
options.parentCommit = options.parentCommit || _getParentCommitFromBranch(this);
676+
677+
// Set parentCommit
678+
// If there is commit in this branch, set parentCommit to last commit of this branch
679+
// otherwise, set parentCommit to this.parentCommit, the start point of this branch
680+
if (!options.parentCommit) {
681+
if (_getLast(this.commits)) {
682+
options.parentCommit = _getLast(this.commits);
683+
} else {
684+
options.parentCommit = this.parentCommit;
685+
}
686+
}
677687

678688
// Special compact mode
679689
if (this.parent.mode === "compact" &&
@@ -729,11 +739,6 @@
729739
options.y = this.offsetY - this.parent.commitOffsetY;
730740
}
731741

732-
// Fork case: Parent commit from parent branch
733-
if (options.parentCommit instanceof Commit === false && this.parentBranch instanceof Branch) {
734-
options.parentCommit = this.parentCommit;
735-
}
736-
737742
// First commit
738743
var isFirstBranch = !(options.parentCommit instanceof Commit);
739744
var isPathBeginning = this.path.length === 0;

0 commit comments

Comments
 (0)