New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use checkout to resolve unmerged binary file conflicts #8060
use checkout to resolve unmerged binary file conflicts #8060
Conversation
Co-Authored-By: Shenghua Chen <xiaozhuang1314@gmail.com>
['add', file.path], | ||
repository.path, | ||
'addConflictedFile' | ||
)).exitCode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎨 not a blocker, but seeing how we poke at the exitCode
within a switch statement a few times I wonder if there's a better way to organize this logic.
- introduce a simple wrapper to de-duplicate the same work that each Git operation does in this function:
/**
* Run a Git command and return whether the exit code indicated success
*
* This defers to the default error handling infrastructure inside if an error
* is encountered.
*/
async function runGitCommand(
args: string[],
path: string,
name: string
): Promise<boolean> {
const { exitCode } = await git(args, path, name)
return exitCode === 0
}
- tidy up the simple case to make it a bit more readable:
case GitStatusEntry.Deleted: {
return await runGitCommand(
['rm', file.path],
repository.path,
'removeConflictedFile'
)
}
- For this new case, we also get a bit more readability:
const choiceFlag =
manualResolution === ManualConflictResolutionKind.theirs
? 'theirs'
: 'ours'
const checkoutCompleted = await runGitCommand(
['checkout', `--${choiceFlag}`, '--', file.path],
repository.path,
'checkoutConflictedFile'
)
if (checkoutCompleted) {
return await runGitCommand(
['add', file.path],
repository.path,
'addConflictedFile'
)
}
return false
This should make the variable exitCode
unnecessary, and you can return assertNever
below to make the compiler happy.
If you're not keen to tackle this case while you're in here, 👍 to tracking this in a fresh issue. Any interest in capturing a test that verifies this behaviour for merge conflicts? |
Testing results are as follows: Rebasing
Merge conflict
Perhaps I was looking for the wrong outcome. Please advise if so. 99dcd8b, mac |
marked with `.skip` for now
I'll be picking this work up and carrying it forward while @outofambit is out this week. Decided to open a new PR for concision rather than add more noise to this one, and keep the PR body of this one preserved for posterity. So I'm closing this as it's superseded by #8097 |
Overview
Closes #8059
Description
it looks like our prior implementation of manual conflict resolution never worked for files that were changed in both branches. this is because it would simply stage whatever state the file was in in the index (probably a weird conflicted state, or whatever was their before the merge/rebase was started).
this PR adds the step of explicitly
git checkout
-ing the desired version of the file before staging it, ensuring we choose the single version of the file the user requested in the UI.we need to double check that this works for merging and rebasing due to this potential complication. (it might check out the opposite version in a rebasing flow, but that should be easy to address if that is the case.)
Release notes
Notes: [Fixed] Manual conflict resolution always added the same file version