fix(snap), add the current checked out version as the parent, not the head #9345
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.
It's easier to explain this with an example: comp1 has 3 versions: 0.0.1, 0.0.2 and 0.0.3. The head points to 0.0.3. This workspace has comp1 checked out to 0.0.2. The user is now running
bit snap
.What should be the parent of this new snap? the checked out version - 0.0.2 or the head - 0.0.3?
Until now, we used the head. In terms of the history, this is incorrect, because it skips the changes done on 0.0.3.
In practice, this is very confusing in the following scenario:
The user now regrets making this snap and to remove it, he/she is running
bit reset
. Because this snap was on top of the head, the reset changes the .bitmap version to the head version - 0.0.3 while leaving the files in the filesystem according to 0.0.2. The user continues and runsbit snap
again. Now, the changes done in 0.0.3 are gone. Investigating when these changes are gone, leads to this new snap, which shows it removes the changes. The user made this snap is not aware of all of this.This PR fixes it by using the checked out version as the parent. This leads to a component being diverged, because on the remote went to another direction since this checked out version. Once the user tries to export, it'll throw an error suggesting to either
bit merge
orbit reset
and snap again.