diff --git a/pkg/integration/tests/patch_building/move_to_index_with_modified_file.go b/pkg/integration/tests/patch_building/move_to_index_with_modified_file.go new file mode 100644 index 000000000..b9af98d15 --- /dev/null +++ b/pkg/integration/tests/patch_building/move_to_index_with_modified_file.go @@ -0,0 +1,64 @@ +package patch_building + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var MoveToIndexWithModifiedFile = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Move a patch from a commit to the index, with a modified file in the working tree that conflicts with the patch", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell.CreateFileAndAdd("file1", "1\n2\n3\n4\n") + shell.Commit("first commit") + shell.UpdateFileAndAdd("file1", "11\n2\n3\n4\n") + shell.Commit("second commit") + shell.UpdateFile("file1", "111\n2\n3\n4\n") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + Focus(). + Lines( + Contains("second commit").IsSelected(), + Contains("first commit"), + ). + PressEnter() + + t.Views().CommitFiles(). + IsFocused(). + Lines( + Equals("M file1"), + ). + PressPrimaryAction() + + t.Views().Information().Content(Contains("Building patch")) + + t.Views().Secondary().Content(Contains("-1\n+11")) + + t.Common().SelectPatchOption(Contains("Move patch out into index")) + + t.ExpectPopup().Confirmation().Title(Equals("Must stash")). + Content(Contains("Pulling a patch out into the index requires stashing and unstashing your changes.")). + Confirm() + + t.Views().Files(). + Focus(). + Lines( + Equals("MM file1"), + ) + + t.Views().Main(). + Content(Contains("-11\n+111\n")) + t.Views().Secondary(). + Content(Contains("-1\n+11\n")) + + /* EXPECTED: + t.Views().Stash().IsEmpty() + ACTUAL: */ + t.Views().Stash().Lines( + Contains("Auto-stashing changes"), + ) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index e1dd36dbf..7d7bcf901 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -310,6 +310,7 @@ var tests = []*components.IntegrationTest{ patch_building.MoveToIndexPartOfAdjacentAddedLines, patch_building.MoveToIndexPartial, patch_building.MoveToIndexWithConflict, + patch_building.MoveToIndexWithModifiedFile, patch_building.MoveToIndexWorksEvenIfNoprefixIsSet, patch_building.MoveToLaterCommit, patch_building.MoveToLaterCommitPartialHunk,