feat(essentials): add enableMergeConflictPrompt
configuration setting
#6126
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.
What's the problem this PR addresses?
Merge conflict auto-fix is a handy feature, but it doesn't give the user much control over how it works. For example, there may be cases where the user would prefer to favor one lockfile variant over another, instead of combining all of them. Consider the following scenario:
1.2.0
), on themain
branchyarn dedupe
) to a later version (1.1.0
), but not the latest version, on a branchmain
git merge main
on their branch, sees the conflictsyarn
to resolve the conflicts, which combines both lockfile variants and, because of how Yarn resolves the similar lockfile entries, ends up with all instances of library X in the lockfile on version1.1.0
While this outcome results in a technically correct lockfile, it is not the outcome that user A wants to see, since they upgraded all instances of library X to
1.2.0
for a good reason.This PR gives user B more control over how merge conflicts will be resolved, which will make user A happy.
How did you fix it?
This PR adds a new
enableMergeConflictPrompt
configuration setting to.yarnrc.yml
; when set, and Yarn detects merge conflicts in the lockfile, Yarn will prompt the user about how they want the merge conflicts to be resolved:combine
: Combine the lockfile variants, which is the current behaviorcurrent
: Use the lockfile on the current branch (HEAD
)incoming
: Use the lockfile on the incoming branch (MERGE_HEAD
orREBASE_HEAD
orCHERRY_PICK_HEAD
)Checklist