|
| 1 | +package conflicts |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/jesseduffield/lazygit/pkg/config" |
| 5 | + . "github.com/jesseduffield/lazygit/pkg/integration/components" |
| 6 | +) |
| 7 | + |
| 8 | +var ResolveNonTextualConflicts = NewIntegrationTest(NewIntegrationTestArgs{ |
| 9 | + Description: "Resolve non-textual merge conflicts (e.g. one side modified, the other side deleted)", |
| 10 | + ExtraCmdArgs: []string{}, |
| 11 | + Skip: false, |
| 12 | + SetupConfig: func(config *config.AppConfig) {}, |
| 13 | + SetupRepo: func(shell *Shell) { |
| 14 | + shell.RunShellCommand(`echo test1 > both-deleted1.txt`) |
| 15 | + shell.RunShellCommand(`echo test2 > both-deleted2.txt`) |
| 16 | + shell.RunShellCommand(`git checkout -b conflict && git add both-deleted1.txt both-deleted2.txt`) |
| 17 | + shell.RunShellCommand(`echo haha1 > deleted-them1.txt && git add deleted-them1.txt`) |
| 18 | + shell.RunShellCommand(`echo haha2 > deleted-them2.txt && git add deleted-them2.txt`) |
| 19 | + shell.RunShellCommand(`echo haha1 > deleted-us1.txt && git add deleted-us1.txt`) |
| 20 | + shell.RunShellCommand(`echo haha2 > deleted-us2.txt && git add deleted-us2.txt`) |
| 21 | + shell.RunShellCommand(`git commit -m one`) |
| 22 | + |
| 23 | + // stuff on other branch |
| 24 | + shell.RunShellCommand(`git branch conflict_second`) |
| 25 | + shell.RunShellCommand(`git mv both-deleted1.txt added-them-changed-us1.txt`) |
| 26 | + shell.RunShellCommand(`git mv both-deleted2.txt added-them-changed-us2.txt`) |
| 27 | + shell.RunShellCommand(`git rm deleted-them1.txt deleted-them2.txt`) |
| 28 | + shell.RunShellCommand(`echo modded1 > deleted-us1.txt && git add deleted-us1.txt`) |
| 29 | + shell.RunShellCommand(`echo modded2 > deleted-us2.txt && git add deleted-us2.txt`) |
| 30 | + shell.RunShellCommand(`git commit -m "two"`) |
| 31 | + |
| 32 | + // stuff on our branch |
| 33 | + shell.RunShellCommand(`git checkout conflict_second`) |
| 34 | + shell.RunShellCommand(`git mv both-deleted1.txt changed-them-added-us1.txt`) |
| 35 | + shell.RunShellCommand(`git mv both-deleted2.txt changed-them-added-us2.txt`) |
| 36 | + shell.RunShellCommand(`echo modded1 > deleted-them1.txt && git add deleted-them1.txt`) |
| 37 | + shell.RunShellCommand(`echo modded2 > deleted-them2.txt && git add deleted-them2.txt`) |
| 38 | + shell.RunShellCommand(`git rm deleted-us1.txt deleted-us2.txt`) |
| 39 | + shell.RunShellCommand(`git commit -m "three"`) |
| 40 | + shell.RunShellCommand(`git reset --hard conflict_second`) |
| 41 | + shell.RunCommandExpectError([]string{"git", "merge", "conflict"}) |
| 42 | + }, |
| 43 | + Run: func(t *TestDriver, keys config.KeybindingConfig) { |
| 44 | + resolve := func(filename string, menuChoice string) { |
| 45 | + t.Views().Files(). |
| 46 | + NavigateToLine(Contains(filename)). |
| 47 | + Tap(func() { |
| 48 | + t.Views().Main().Content(Contains("Conflict:")) |
| 49 | + }). |
| 50 | + Press(keys.Universal.GoInto). |
| 51 | + Tap(func() { |
| 52 | + t.ExpectPopup().Menu().Title(Equals("Merge conflicts")). |
| 53 | + Select(Contains(menuChoice)). |
| 54 | + Confirm() |
| 55 | + }) |
| 56 | + } |
| 57 | + |
| 58 | + t.Views().Files(). |
| 59 | + IsFocused(). |
| 60 | + Lines( |
| 61 | + Equals("▼ /").IsSelected(), |
| 62 | + Equals(" UA added-them-changed-us1.txt"), |
| 63 | + Equals(" UA added-them-changed-us2.txt"), |
| 64 | + Equals(" DD both-deleted1.txt"), |
| 65 | + Equals(" DD both-deleted2.txt"), |
| 66 | + Equals(" AU changed-them-added-us1.txt"), |
| 67 | + Equals(" AU changed-them-added-us2.txt"), |
| 68 | + Equals(" UD deleted-them1.txt"), |
| 69 | + Equals(" UD deleted-them2.txt"), |
| 70 | + Equals(" DU deleted-us1.txt"), |
| 71 | + Equals(" DU deleted-us2.txt"), |
| 72 | + ). |
| 73 | + Tap(func() { |
| 74 | + resolve("added-them-changed-us1.txt", "Delete file") |
| 75 | + resolve("added-them-changed-us2.txt", "Keep file") |
| 76 | + resolve("both-deleted1.txt", "Delete file") |
| 77 | + resolve("both-deleted2.txt", "Delete file") |
| 78 | + resolve("changed-them-added-us1.txt", "Delete file") |
| 79 | + resolve("changed-them-added-us2.txt", "Keep file") |
| 80 | + resolve("deleted-them1.txt", "Delete file") |
| 81 | + resolve("deleted-them2.txt", "Keep file") |
| 82 | + resolve("deleted-us1.txt", "Delete file") |
| 83 | + resolve("deleted-us2.txt", "Keep file") |
| 84 | + }). |
| 85 | + Lines( |
| 86 | + Equals("▼ /"), |
| 87 | + Equals(" A added-them-changed-us2.txt"), |
| 88 | + Equals(" D changed-them-added-us1.txt"), |
| 89 | + Equals(" D deleted-them1.txt"), |
| 90 | + Equals(" A deleted-us2.txt"), |
| 91 | + ) |
| 92 | + |
| 93 | + t.FileSystem(). |
| 94 | + PathNotPresent("added-them-changed-us1.txt"). |
| 95 | + FileContent("added-them-changed-us2.txt", Equals("test2\n")). |
| 96 | + PathNotPresent("both-deleted1.txt"). |
| 97 | + PathNotPresent("both-deleted2.txt"). |
| 98 | + PathNotPresent("changed-them-added-us1.txt"). |
| 99 | + FileContent("changed-them-added-us2.txt", Equals("test2\n")). |
| 100 | + PathNotPresent("deleted-them1.txt"). |
| 101 | + FileContent("deleted-them2.txt", Equals("modded2\n")). |
| 102 | + PathNotPresent("deleted-us1.txt"). |
| 103 | + FileContent("deleted-us2.txt", Equals("modded2\n")) |
| 104 | + }, |
| 105 | +}) |
0 commit comments