add parseMergeResult functionality and tests to detect merge conflicts #5493
add parseMergeResult functionality and tests to detect merge conflicts #5493
Conversation
b1f8caa to
27afdc8
Compare
| ours: Branch, | ||
| theirs: Branch | ||
| ): Promise<MergeResult | null> { | ||
| console.time('getMergeBase') |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
app/src/lib/git/merge.ts
Outdated
| /** | ||
| * Find the base commit between two refs | ||
| * | ||
| * @returns the commit id of the merge base, or null if the two refs do not |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| 'merge-base' | ||
| 'merge-base', | ||
| { | ||
| successExitCodes: new Set([0, 1]), |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
app/src/lib/git/merge.ts
Outdated
| } | ||
|
|
||
| if (mergeBase === ours.tip.sha) { | ||
| return { kind: MergeResultKind.Success, entries: [] } |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
app/src/lib/merge-tree-parser.ts
Outdated
| function updateCurrentMergeEntry( | ||
| entry: IMergeEntry | undefined, | ||
| context: string, | ||
| blobSource: { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
iAmWillShepherd
left a comment
There was a problem hiding this comment.
Only thing needed is some unit tests, is that something you want to do in a separate PR, so this one wont be held up?
This PR is the underlying Git work to support #4588. I generated a bunch of test data by scanning the
desktop/desktop,electron/electronandmicrosoft/vscoderepositories for examples of merge conflicts - these are now baked as tests into the project, and caught some corner cases I hadn't uncovered with the original code.For the moment
parseMergeResultjust scans the Git output to build up an array of entries, to then determine what files have conflict. But there's already details in the diff output about how files conflict that we can use down the track.For reference, this is how I generated the merge conflict files - if there's interest in me adding this as something more reusable to regenerate tests cases when we upgrade
dugitelet me know and we can figure out how to do that: