This repository has been archived by the owner on Jul 13, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Relate Issue:
Issue #159
The Problem:
The following source code will create wrong branch arrow.
The arrow pointed to r1 commit will pointed from second commit of m1
not follow the line from first commit of m1.
The Cause:
When create a commit, if user does not specify parent commit in options
gitgraph.js will execute following code:
to determine the parent commit of the created commit.
In the function
_getParentCommitFromBranch
, it will try to get the lastcommit from current branch, then from parent branch. Since
r1.commit()
is the first commit in its branch
1.0.x
, it will set its parent committo last commit of its parent branch, that is
master
. And since masteralready add some new commit, the arrow will point from wrong commit, the
last commit of
master
branch.There is code that deal with branch case:
It set
parentCommit
to the correct commit. However, sinceoptions.parentCommit
already been set by previous code, this code willnever execute since
options.parentCommit
is always a Commit.The fix:
The fix is combining two scenario. If current branch already has commits,
the parentCommit will be set to last commit in this branch. Otherwise,
it will set to parent commit of this branch, which will be the correct commit
instead of last commit of parent branch.