|
| 1 | +package patch_building |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/jesseduffield/lazygit/pkg/config" |
| 5 | + . "github.com/jesseduffield/lazygit/pkg/integration/components" |
| 6 | +) |
| 7 | + |
| 8 | +var MoveToEarlierCommitFromAddedFile = NewIntegrationTest(NewIntegrationTestArgs{ |
| 9 | + Description: "Move a patch from a file that was added in a commit to an earlier commit", |
| 10 | + ExtraCmdArgs: []string{}, |
| 11 | + Skip: false, |
| 12 | + SetupConfig: func(config *config.AppConfig) {}, |
| 13 | + SetupRepo: func(shell *Shell) { |
| 14 | + shell.EmptyCommit("first commit") |
| 15 | + shell.EmptyCommit("destination commit") |
| 16 | + shell.CreateFileAndAdd("file1", "1st line\n2nd line\n3rd line\n") |
| 17 | + shell.Commit("commit to move from") |
| 18 | + }, |
| 19 | + Run: func(t *TestDriver, keys config.KeybindingConfig) { |
| 20 | + t.Views().Commits(). |
| 21 | + Focus(). |
| 22 | + Lines( |
| 23 | + Contains("commit to move from").IsSelected(), |
| 24 | + Contains("destination commit"), |
| 25 | + Contains("first commit"), |
| 26 | + ). |
| 27 | + PressEnter() |
| 28 | + |
| 29 | + t.Views().CommitFiles(). |
| 30 | + IsFocused(). |
| 31 | + Lines( |
| 32 | + Contains("A file").IsSelected(), |
| 33 | + ). |
| 34 | + PressEnter() |
| 35 | + |
| 36 | + t.Views().PatchBuilding(). |
| 37 | + IsFocused(). |
| 38 | + SelectNextItem(). |
| 39 | + PressPrimaryAction() |
| 40 | + |
| 41 | + t.Views().Information().Content(Contains("Building patch")) |
| 42 | + |
| 43 | + t.Views().Commits(). |
| 44 | + Focus(). |
| 45 | + SelectNextItem() |
| 46 | + |
| 47 | + t.Common().SelectPatchOption(Contains("Move patch to selected commit")) |
| 48 | + |
| 49 | + // This results in a conflict at the commit we're moving from, because |
| 50 | + // it tries to add a file that already exists |
| 51 | + t.Common().AcknowledgeConflicts() |
| 52 | + |
| 53 | + t.Views().Files(). |
| 54 | + IsFocused(). |
| 55 | + Lines( |
| 56 | + Contains("AA").Contains("file"), |
| 57 | + ). |
| 58 | + PressEnter() |
| 59 | + |
| 60 | + t.Views().MergeConflicts(). |
| 61 | + IsFocused(). |
| 62 | + TopLines( |
| 63 | + Contains("<<<<<<< HEAD"), |
| 64 | + Contains("2nd line"), |
| 65 | + Contains("======="), |
| 66 | + Contains("1st line"), |
| 67 | + Contains("2nd line"), |
| 68 | + Contains("3rd line"), |
| 69 | + Contains(">>>>>>>"), |
| 70 | + ). |
| 71 | + SelectNextItem(). |
| 72 | + PressPrimaryAction() // choose the version with all three lines |
| 73 | + |
| 74 | + t.Common().ContinueOnConflictsResolved() |
| 75 | + |
| 76 | + t.Views().Commits(). |
| 77 | + Focus(). |
| 78 | + Lines( |
| 79 | + Contains("commit to move from"), |
| 80 | + Contains("destination commit").IsSelected(), |
| 81 | + Contains("first commit"), |
| 82 | + ). |
| 83 | + PressEnter() |
| 84 | + |
| 85 | + t.Views().CommitFiles(). |
| 86 | + IsFocused(). |
| 87 | + Lines( |
| 88 | + Contains("A file").IsSelected(), |
| 89 | + ). |
| 90 | + Tap(func() { |
| 91 | + t.Views().Main().ContainsLines( |
| 92 | + Equals("+2nd line"), |
| 93 | + ) |
| 94 | + }). |
| 95 | + PressEscape() |
| 96 | + |
| 97 | + t.Views().Commits(). |
| 98 | + IsFocused(). |
| 99 | + NavigateToLine(Contains("commit to move from")). |
| 100 | + PressEnter() |
| 101 | + |
| 102 | + t.Views().CommitFiles(). |
| 103 | + IsFocused(). |
| 104 | + Lines( |
| 105 | + Contains("M file").IsSelected(), |
| 106 | + ). |
| 107 | + Tap(func() { |
| 108 | + t.Views().Main().ContainsLines( |
| 109 | + Equals("+1st line"), |
| 110 | + Equals(" 2nd line"), |
| 111 | + Equals("+3rd line"), |
| 112 | + ) |
| 113 | + }) |
| 114 | + }, |
| 115 | +}) |
0 commit comments