diff --git a/pkg/integration/tests/patch_building/renamed_file_partial.go b/pkg/integration/tests/main_view/remove_content_change_from_renamed_file.go similarity index 52% rename from pkg/integration/tests/patch_building/renamed_file_partial.go rename to pkg/integration/tests/main_view/remove_content_change_from_renamed_file.go index 3c37c13a2..dbcacb160 100644 --- a/pkg/integration/tests/patch_building/renamed_file_partial.go +++ b/pkg/integration/tests/main_view/remove_content_change_from_renamed_file.go @@ -1,15 +1,17 @@ -package patch_building +package main_view import ( "github.com/jesseduffield/lazygit/pkg/config" . "github.com/jesseduffield/lazygit/pkg/integration/components" ) -var RenamedFilePartial = NewIntegrationTest(NewIntegrationTestArgs{ - Description: "Select part of a renamed file's changes into a custom patch and remove it from the commit, keeping the rename in place", +var RemoveContentChangeFromRenamedFile = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Remove a renamed file's content change from a commit while keeping its rename", ExtraCmdArgs: []string{}, Skip: false, - SetupConfig: func(config *config.AppConfig) {}, + SetupConfig: func(config *config.AppConfig) { + config.GetUserConfig().Gui.UseHunkModeInStagingView = false + }, SetupRepo: func(shell *Shell) { shell.CreateFileAndAdd("original", "line1\nline2\nline3\nline4\nline5\n") shell.Commit("first commit") @@ -32,42 +34,50 @@ var RenamedFilePartial = NewIntegrationTest(NewIntegrationTestArgs{ Lines( Contains("original → renamed").IsSelected(), ). - PressEnter() + Press(keys.Universal.FocusMainView) - // The main view shows the rename together with its content change. - t.Views().PatchBuilding(). + t.Views().Main(). IsFocused(). Content(Contains("rename from original").Contains("rename to renamed")). + SelectedLines(Contains("-line2")). + Press(keys.Universal.ToggleRangeSelect). + Press(keys.Universal.NextItem). + SelectedLines( + Contains("-line2"), + Contains("+line2 changed"), + ). + PressPrimaryAction() + + t.Views().Information().Content(Contains("Building patch")) + + // Only part of the file is in the patch, so the patch leaves the rename behind in + // the commit and carries the content change alone. The pane beside the diff shows + // it that way, over the name the file was renamed to. + t.Views().Secondary(). + ContainsLines( + Contains("diff --git a/renamed b/renamed"), + Contains("index"), + Contains("--- a/renamed"), + Contains("+++ b/renamed"), + ). ContainsLines( Contains(" line1"), Contains("-line2"), Contains("+line2 changed"), Contains(" line3"), - ). - // Add the hunk (a line selection, as opposed to adding the whole - // file), so this is a partial patch. - PressPrimaryAction() - - t.Views().Information().Content(Contains("Building patch")) + ) t.Common().SelectPatchOption(Contains("Remove patch from original commit")) - // The rename is preserved; only the content change is gone, so the file - // is still shown as a rename but now has no content change. - t.Views().CommitFiles(). - IsFocused(). - Lines( - Contains("original → renamed").IsSelected(), - ) - + t.Views().CommitFiles().Lines( + Contains("original → renamed").IsSelected(), + ) t.Views().Main(). + IsFocused(). Content(DoesNotContain("line2 changed")) - - t.Views().Commits(). - Focus(). - Lines( - Contains("rename with modification").IsSelected(), - Contains("first commit"), - ) + t.Views().Commits().Lines( + Contains("rename with modification").IsSelected(), + Contains("first commit"), + ) }, }) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 01a5b0870..05d491341 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -444,6 +444,7 @@ var tests = []*components.IntegrationTest{ main_view.PatchMarksShowWheneverTheirDiffIsOnScreen, main_view.RangeSelectDiffLines, main_view.RawFallbackUnderAnExternalDiff, + main_view.RemoveContentChangeFromRenamedFile, main_view.RemoveLinesFromTheCustomPatch, main_view.RemovePartOfAddedFileFromCommit, main_view.RemovePatchFromCommit, @@ -497,7 +498,6 @@ var tests = []*components.IntegrationTest{ misc.StartInGitDir, patch_building.CopyRenamedFileDiff, patch_building.RenameSimilarityThresholdChange, - patch_building.RenamedFilePartial, patch_building.RenamedFileWhole, patch_building.SelectAllFiles, patch_building.SelectDirecoriesSharingPrefix,