|
| 1 | +package cherry_pick |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/jesseduffield/lazygit/pkg/config" |
| 5 | + . "github.com/jesseduffield/lazygit/pkg/integration/components" |
| 6 | +) |
| 7 | + |
| 8 | +var CherryPickMerge = NewIntegrationTest(NewIntegrationTestArgs{ |
| 9 | + Description: "Cherry pick a merge commit", |
| 10 | + ExtraCmdArgs: []string{}, |
| 11 | + Skip: false, |
| 12 | + SetupConfig: func(config *config.AppConfig) {}, |
| 13 | + SetupRepo: func(shell *Shell) { |
| 14 | + shell. |
| 15 | + EmptyCommit("base"). |
| 16 | + NewBranch("first-branch"). |
| 17 | + NewBranch("second-branch"). |
| 18 | + Checkout("first-branch"). |
| 19 | + Checkout("second-branch"). |
| 20 | + CreateFileAndAdd("file1.txt", "content"). |
| 21 | + Commit("one"). |
| 22 | + CreateFileAndAdd("file2.txt", "content"). |
| 23 | + Commit("two"). |
| 24 | + Checkout("master"). |
| 25 | + Merge("second-branch"). |
| 26 | + Checkout("first-branch") |
| 27 | + }, |
| 28 | + Run: func(t *TestDriver, keys config.KeybindingConfig) { |
| 29 | + t.Views().Branches(). |
| 30 | + Focus(). |
| 31 | + Lines( |
| 32 | + Contains("first-branch"), |
| 33 | + Contains("master"), |
| 34 | + Contains("second-branch"), |
| 35 | + ). |
| 36 | + SelectNextItem(). |
| 37 | + PressEnter() |
| 38 | + |
| 39 | + t.Views().SubCommits(). |
| 40 | + IsFocused(). |
| 41 | + Lines( |
| 42 | + Contains("⏣─╮ Merge branch 'second-branch'").IsSelected(), |
| 43 | + Contains("│ ◯ two"), |
| 44 | + Contains("│ ◯ one"), |
| 45 | + Contains("◯ ╯ base"), |
| 46 | + ). |
| 47 | + // copy the merge commit |
| 48 | + Press(keys.Commits.CherryPickCopy) |
| 49 | + |
| 50 | + t.Views().Information().Content(Contains("1 commit copied")) |
| 51 | + |
| 52 | + t.Views().Commits(). |
| 53 | + Focus(). |
| 54 | + Lines( |
| 55 | + Contains("base").IsSelected(), |
| 56 | + ). |
| 57 | + Press(keys.Commits.PasteCommits). |
| 58 | + Tap(func() { |
| 59 | + t.ExpectPopup().Alert(). |
| 60 | + Title(Equals("Cherry-pick")). |
| 61 | + Content(Contains("Are you sure you want to cherry-pick the 1 copied commit(s) onto this branch?")). |
| 62 | + Confirm() |
| 63 | + }). |
| 64 | + Tap(func() { |
| 65 | + t.Views().Information().Content(DoesNotContain("commit copied")) |
| 66 | + }). |
| 67 | + Lines( |
| 68 | + Contains("Merge branch 'second-branch'").IsSelected(), |
| 69 | + Contains("base"), |
| 70 | + ) |
| 71 | + |
| 72 | + t.Views().Main().ContainsLines( |
| 73 | + Contains("Merge branch 'second-branch'"), |
| 74 | + Contains("---"), |
| 75 | + Contains("file1.txt | 1 +"), |
| 76 | + Contains("file2.txt | 1 +"), |
| 77 | + Contains("2 files changed, 2 insertions(+)"), |
| 78 | + ) |
| 79 | + }, |
| 80 | +}) |
0 commit comments