-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Resolve non-inline merge conflicts #4431
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
pkg/integration/tests/conflicts/resolve_non_textual_conflicts.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
package conflicts | ||
|
||
import ( | ||
"github.com/jesseduffield/lazygit/pkg/config" | ||
. "github.com/jesseduffield/lazygit/pkg/integration/components" | ||
) | ||
|
||
var ResolveNonTextualConflicts = NewIntegrationTest(NewIntegrationTestArgs{ | ||
Description: "Resolve non-textual merge conflicts (e.g. one side modified, the other side deleted)", | ||
ExtraCmdArgs: []string{}, | ||
Skip: false, | ||
SetupConfig: func(config *config.AppConfig) {}, | ||
SetupRepo: func(shell *Shell) { | ||
shell.RunShellCommand(`echo test1 > both-deleted1.txt`) | ||
shell.RunShellCommand(`echo test2 > both-deleted2.txt`) | ||
shell.RunShellCommand(`git checkout -b conflict && git add both-deleted1.txt both-deleted2.txt`) | ||
shell.RunShellCommand(`echo haha1 > deleted-them1.txt && git add deleted-them1.txt`) | ||
shell.RunShellCommand(`echo haha2 > deleted-them2.txt && git add deleted-them2.txt`) | ||
shell.RunShellCommand(`echo haha1 > deleted-us1.txt && git add deleted-us1.txt`) | ||
shell.RunShellCommand(`echo haha2 > deleted-us2.txt && git add deleted-us2.txt`) | ||
shell.RunShellCommand(`git commit -m one`) | ||
|
||
// stuff on other branch | ||
shell.RunShellCommand(`git branch conflict_second`) | ||
shell.RunShellCommand(`git mv both-deleted1.txt added-them-changed-us1.txt`) | ||
shell.RunShellCommand(`git mv both-deleted2.txt added-them-changed-us2.txt`) | ||
shell.RunShellCommand(`git rm deleted-them1.txt deleted-them2.txt`) | ||
shell.RunShellCommand(`echo modded1 > deleted-us1.txt && git add deleted-us1.txt`) | ||
shell.RunShellCommand(`echo modded2 > deleted-us2.txt && git add deleted-us2.txt`) | ||
shell.RunShellCommand(`git commit -m "two"`) | ||
|
||
// stuff on our branch | ||
shell.RunShellCommand(`git checkout conflict_second`) | ||
shell.RunShellCommand(`git mv both-deleted1.txt changed-them-added-us1.txt`) | ||
shell.RunShellCommand(`git mv both-deleted2.txt changed-them-added-us2.txt`) | ||
shell.RunShellCommand(`echo modded1 > deleted-them1.txt && git add deleted-them1.txt`) | ||
shell.RunShellCommand(`echo modded2 > deleted-them2.txt && git add deleted-them2.txt`) | ||
shell.RunShellCommand(`git rm deleted-us1.txt deleted-us2.txt`) | ||
shell.RunShellCommand(`git commit -m "three"`) | ||
shell.RunShellCommand(`git reset --hard conflict_second`) | ||
shell.RunCommandExpectError([]string{"git", "merge", "conflict"}) | ||
}, | ||
Run: func(t *TestDriver, keys config.KeybindingConfig) { | ||
resolve := func(filename string, menuChoice string) { | ||
t.Views().Files(). | ||
NavigateToLine(Contains(filename)). | ||
Tap(func() { | ||
t.Views().Main().Content(Contains("Conflict:")) | ||
}). | ||
Press(keys.Universal.GoInto). | ||
Tap(func() { | ||
t.ExpectPopup().Menu().Title(Equals("Merge conflicts")). | ||
Select(Contains(menuChoice)). | ||
Confirm() | ||
}) | ||
} | ||
|
||
t.Views().Files(). | ||
IsFocused(). | ||
Lines( | ||
Equals("▼ /").IsSelected(), | ||
Equals(" UA added-them-changed-us1.txt"), | ||
Equals(" UA added-them-changed-us2.txt"), | ||
Equals(" DD both-deleted1.txt"), | ||
Equals(" DD both-deleted2.txt"), | ||
Equals(" AU changed-them-added-us1.txt"), | ||
Equals(" AU changed-them-added-us2.txt"), | ||
Equals(" UD deleted-them1.txt"), | ||
Equals(" UD deleted-them2.txt"), | ||
Equals(" DU deleted-us1.txt"), | ||
Equals(" DU deleted-us2.txt"), | ||
). | ||
Tap(func() { | ||
resolve("added-them-changed-us1.txt", "Delete file") | ||
resolve("added-them-changed-us2.txt", "Keep file") | ||
resolve("both-deleted1.txt", "Delete file") | ||
resolve("both-deleted2.txt", "Delete file") | ||
resolve("changed-them-added-us1.txt", "Delete file") | ||
resolve("changed-them-added-us2.txt", "Keep file") | ||
resolve("deleted-them1.txt", "Delete file") | ||
resolve("deleted-them2.txt", "Keep file") | ||
resolve("deleted-us1.txt", "Delete file") | ||
resolve("deleted-us2.txt", "Keep file") | ||
}). | ||
Lines( | ||
Equals("▼ /"), | ||
Equals(" A added-them-changed-us2.txt"), | ||
Equals(" D changed-them-added-us1.txt"), | ||
Equals(" D deleted-them1.txt"), | ||
Equals(" A deleted-us2.txt"), | ||
) | ||
|
||
t.FileSystem(). | ||
PathNotPresent("added-them-changed-us1.txt"). | ||
FileContent("added-them-changed-us2.txt", Equals("test2\n")). | ||
PathNotPresent("both-deleted1.txt"). | ||
PathNotPresent("both-deleted2.txt"). | ||
PathNotPresent("changed-them-added-us1.txt"). | ||
FileContent("changed-them-added-us2.txt", Equals("test2\n")). | ||
PathNotPresent("deleted-them1.txt"). | ||
FileContent("deleted-them2.txt", Equals("modded2\n")). | ||
PathNotPresent("deleted-us1.txt"). | ||
FileContent("deleted-us2.txt", Equals("modded2\n")) | ||
}, | ||
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
I would have put them both in the same order so that you can use muscle memory to make the choice. Given that this second one is 50/50, why not just retain the order of the first one? i.e. always have delete first.
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.
I found it more important not to have a destructive option as a default. And these AU/UA conflicts are so rare and probably so confusing that you won't be able to operate the dialog quickly and using muscle memory without looking. You'll have to read the choices carefully.
I'd prefer to keep the order this way, but I can also change it if you insist.
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.
Alright fair, let's keep it as-is