2022-09-17 07:15:02 +02:00
|
|
|
package cherry_pick
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/jesseduffield/lazygit/pkg/config"
|
|
|
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
|
|
|
"github.com/jesseduffield/lazygit/pkg/integration/tests/shared"
|
|
|
|
)
|
|
|
|
|
|
|
|
var CherryPickConflicts = NewIntegrationTest(NewIntegrationTestArgs{
|
|
|
|
Description: "Cherry pick commits from the subcommits view, with conflicts",
|
2023-05-21 09:00:29 +02:00
|
|
|
ExtraCmdArgs: []string{},
|
2022-09-17 07:15:02 +02:00
|
|
|
Skip: false,
|
|
|
|
SetupConfig: func(config *config.AppConfig) {},
|
|
|
|
SetupRepo: func(shell *Shell) {
|
|
|
|
shared.MergeConflictsSetup(shell)
|
|
|
|
},
|
2022-12-27 12:47:37 +02:00
|
|
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
2022-12-27 12:35:36 +02:00
|
|
|
t.Views().Branches().
|
2022-12-27 07:27:36 +02:00
|
|
|
Focus().
|
|
|
|
Lines(
|
|
|
|
Contains("first-change-branch"),
|
|
|
|
Contains("second-change-branch"),
|
|
|
|
Contains("original-branch"),
|
|
|
|
).
|
|
|
|
SelectNextItem().
|
|
|
|
PressEnter()
|
|
|
|
|
2022-12-27 12:35:36 +02:00
|
|
|
t.Views().SubCommits().
|
2022-12-27 07:27:36 +02:00
|
|
|
IsFocused().
|
|
|
|
TopLines(
|
|
|
|
Contains("second-change-branch unrelated change"),
|
|
|
|
Contains("second change"),
|
|
|
|
).
|
2022-12-27 12:25:11 +02:00
|
|
|
Press(keys.Commits.CherryPickCopy).
|
|
|
|
Tap(func() {
|
2022-12-27 12:35:36 +02:00
|
|
|
t.Views().Information().Content(Contains("1 commit copied"))
|
2022-12-27 12:25:11 +02:00
|
|
|
}).
|
2022-12-27 07:27:36 +02:00
|
|
|
SelectNextItem().
|
|
|
|
Press(keys.Commits.CherryPickCopy)
|
|
|
|
|
2022-12-27 12:35:36 +02:00
|
|
|
t.Views().Information().Content(Contains("2 commits copied"))
|
2022-12-27 07:27:36 +02:00
|
|
|
|
2022-12-27 12:35:36 +02:00
|
|
|
t.Views().Commits().
|
2022-12-27 07:27:36 +02:00
|
|
|
Focus().
|
|
|
|
TopLines(
|
|
|
|
Contains("first change"),
|
|
|
|
).
|
|
|
|
Press(keys.Commits.PasteCommits)
|
|
|
|
|
2023-02-22 12:15:03 +02:00
|
|
|
t.ExpectPopup().Alert().
|
2023-05-25 13:11:51 +02:00
|
|
|
Title(Equals("Cherry-pick")).
|
2023-02-22 12:15:03 +02:00
|
|
|
Content(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")).
|
|
|
|
Confirm()
|
2022-12-27 07:27:36 +02:00
|
|
|
|
2023-02-26 02:49:15 +02:00
|
|
|
t.Common().AcknowledgeConflicts()
|
2022-09-17 07:15:02 +02:00
|
|
|
|
2022-12-27 12:35:36 +02:00
|
|
|
t.Views().Files().
|
2022-12-27 07:27:36 +02:00
|
|
|
IsFocused().
|
|
|
|
SelectedLine(Contains("file")).
|
|
|
|
PressEnter()
|
2022-09-17 07:15:02 +02:00
|
|
|
|
2022-12-27 12:35:36 +02:00
|
|
|
t.Views().MergeConflicts().
|
2022-12-27 07:27:36 +02:00
|
|
|
IsFocused().
|
|
|
|
// picking 'Second change'
|
|
|
|
SelectNextItem().
|
|
|
|
PressPrimaryAction()
|
2022-09-17 07:15:02 +02:00
|
|
|
|
2023-02-26 02:49:15 +02:00
|
|
|
t.Common().ContinueOnConflictsResolved()
|
2022-09-17 07:15:02 +02:00
|
|
|
|
2022-12-27 13:52:20 +02:00
|
|
|
t.Views().Files().IsEmpty()
|
2022-09-17 07:15:02 +02:00
|
|
|
|
2022-12-27 12:35:36 +02:00
|
|
|
t.Views().Commits().
|
2022-12-27 07:27:36 +02:00
|
|
|
Focus().
|
|
|
|
TopLines(
|
|
|
|
Contains("second-change-branch unrelated change"),
|
|
|
|
Contains("second change"),
|
|
|
|
Contains("first change"),
|
|
|
|
).
|
2022-12-27 12:25:11 +02:00
|
|
|
SelectNextItem().
|
|
|
|
Tap(func() {
|
|
|
|
// because we picked 'Second change' when resolving the conflict,
|
|
|
|
// we now see this commit as having replaced First Change with Second Change,
|
|
|
|
// as opposed to replacing 'Original' with 'Second change'
|
2022-12-27 12:35:36 +02:00
|
|
|
t.Views().Main().
|
2022-12-27 12:25:11 +02:00
|
|
|
Content(Contains("-First Change")).
|
|
|
|
Content(Contains("+Second Change"))
|
|
|
|
|
2022-12-27 12:35:36 +02:00
|
|
|
t.Views().Information().Content(Contains("2 commits copied"))
|
2022-12-27 12:25:11 +02:00
|
|
|
}).
|
|
|
|
PressEscape().
|
|
|
|
Tap(func() {
|
2022-12-27 12:35:36 +02:00
|
|
|
t.Views().Information().Content(DoesNotContain("commits copied"))
|
2022-12-27 12:25:11 +02:00
|
|
|
})
|
2022-09-17 07:15:02 +02:00
|
|
|
},
|
|
|
|
})
|