mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-10-06 05:57:38 -04:00
Move whole-patch destination tests onto the commit diff
Moving a complete patch must preserve each file operation whether its destination is a new commit before or after the source, or an existing commit earlier or later in history. Build those patches as ranges over the focused diff so the coverage survives removal of directory toggling in the patch builder. Co-Authored-By: GitHub Copilot <copilot@github.com>
This commit is contained in:
co-authored by
GitHub Copilot
parent
4e76919866
commit
741561fa7d
+14
-11
@@ -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 MoveToEarlierCommit = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
var MovePatchToEarlierCommit = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Move a patch from a commit to an earlier commit",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupConfig: func(config *config.AppConfig) {
|
||||
config.GetUserConfig().Gui.UseHunkModeInStagingView = false
|
||||
},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.CreateDir("dir")
|
||||
shell.CreateFileAndAdd("dir/file1", "file1 content")
|
||||
@@ -42,15 +44,17 @@ var MoveToEarlierCommit = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Contains(" D file2"),
|
||||
Contains(" A file3"),
|
||||
).
|
||||
PressPrimaryAction().
|
||||
PressEscape()
|
||||
Press(keys.Universal.FocusMainView)
|
||||
|
||||
t.Views().Main().
|
||||
IsFocused().
|
||||
SelectedLines(Contains("-file1 content")).
|
||||
Press(keys.Universal.ToggleRangeSelect).
|
||||
NavigateToLine(Contains("+file3 content")).
|
||||
PressPrimaryAction()
|
||||
|
||||
t.Views().Information().Content(Contains("Building patch"))
|
||||
|
||||
t.Views().Commits().
|
||||
IsFocused().
|
||||
SelectNextItem()
|
||||
|
||||
t.Views().Commits().Focus().SelectNextItem()
|
||||
t.Common().SelectPatchOption(Contains("Move patch to selected commit"))
|
||||
|
||||
t.Views().Commits().
|
||||
@@ -79,7 +83,6 @@ var MoveToEarlierCommit = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
SelectPreviousItem().
|
||||
PressEnter()
|
||||
|
||||
// the original commit has no more files in it
|
||||
t.Views().CommitFiles().
|
||||
IsFocused().
|
||||
Lines(
|
||||
+14
-11
@@ -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 MoveToLaterCommit = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
var MovePatchToLaterCommit = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Move a patch from a commit to a later commit",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupConfig: func(config *config.AppConfig) {
|
||||
config.GetUserConfig().Gui.UseHunkModeInStagingView = false
|
||||
},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.CreateDir("dir")
|
||||
shell.CreateFileAndAdd("dir/file1", "file1 content")
|
||||
@@ -43,15 +45,17 @@ var MoveToLaterCommit = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Contains(" D file2"),
|
||||
Contains(" A file3"),
|
||||
).
|
||||
PressPrimaryAction().
|
||||
PressEscape()
|
||||
Press(keys.Universal.FocusMainView)
|
||||
|
||||
t.Views().Main().
|
||||
IsFocused().
|
||||
SelectedLines(Contains("-file1 content")).
|
||||
Press(keys.Universal.ToggleRangeSelect).
|
||||
NavigateToLine(Contains("+file3 content")).
|
||||
PressPrimaryAction()
|
||||
|
||||
t.Views().Information().Content(Contains("Building patch"))
|
||||
|
||||
t.Views().Commits().
|
||||
IsFocused().
|
||||
SelectPreviousItem()
|
||||
|
||||
t.Views().Commits().Focus().SelectPreviousItem()
|
||||
t.Common().SelectPatchOption(Contains("Move patch to selected commit"))
|
||||
|
||||
t.Views().Commits().
|
||||
@@ -80,7 +84,6 @@ var MoveToLaterCommit = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
SelectNextItem().
|
||||
PressEnter()
|
||||
|
||||
// the original commit has no more files in it
|
||||
t.Views().CommitFiles().
|
||||
IsFocused().
|
||||
Lines(
|
||||
+13
-13
@@ -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 MoveToNewCommit = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
var MovePatchToNewCommit = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Move a patch from a commit to a new commit",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupConfig: func(config *config.AppConfig) {
|
||||
config.GetUserConfig().Gui.UseHunkModeInStagingView = false
|
||||
},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.CreateDir("dir")
|
||||
shell.CreateFileAndAdd("dir/file1", "file1 content")
|
||||
@@ -43,11 +45,16 @@ var MoveToNewCommit = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Contains(" D file2"),
|
||||
Contains(" A file3"),
|
||||
).
|
||||
PressPrimaryAction().
|
||||
PressEscape()
|
||||
Press(keys.Universal.FocusMainView)
|
||||
|
||||
t.Views().Main().
|
||||
IsFocused().
|
||||
SelectedLines(Contains("-file1 content")).
|
||||
Press(keys.Universal.ToggleRangeSelect).
|
||||
NavigateToLine(Contains("+file3 content")).
|
||||
PressPrimaryAction()
|
||||
|
||||
t.Views().Information().Content(Contains("Building patch"))
|
||||
|
||||
t.Common().SelectPatchOption(Contains("Move patch into new commit after the original commit"))
|
||||
|
||||
t.ExpectPopup().CommitMessagePanel().
|
||||
@@ -76,16 +83,9 @@ var MoveToNewCommit = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
|
||||
t.Views().Commits().
|
||||
IsFocused().
|
||||
Lines(
|
||||
Contains("third commit"),
|
||||
Contains("new commit").IsSelected(),
|
||||
Contains("commit to move from"),
|
||||
Contains("first commit"),
|
||||
).
|
||||
SelectNextItem().
|
||||
PressEnter()
|
||||
|
||||
// the original commit has no more files in it
|
||||
t.Views().CommitFiles().
|
||||
IsFocused().
|
||||
Lines(
|
||||
+14
-8
@@ -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 MoveToNewCommitBefore = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Move a patch from a commit to a new commit before the original one",
|
||||
var MovePatchToNewCommitBefore = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Move a patch from a commit to a new commit before the source",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupConfig: func(config *config.AppConfig) {
|
||||
config.GetUserConfig().Gui.UseHunkModeInStagingView = false
|
||||
},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.CreateDir("dir")
|
||||
shell.CreateFileAndAdd("dir/file1", "file1 content")
|
||||
@@ -43,11 +45,16 @@ var MoveToNewCommitBefore = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Contains(" D file2"),
|
||||
Contains(" A file3"),
|
||||
).
|
||||
PressPrimaryAction().
|
||||
PressEscape()
|
||||
Press(keys.Universal.FocusMainView)
|
||||
|
||||
t.Views().Main().
|
||||
IsFocused().
|
||||
SelectedLines(Contains("-file1 content")).
|
||||
Press(keys.Universal.ToggleRangeSelect).
|
||||
NavigateToLine(Contains("+file3 content")).
|
||||
PressPrimaryAction()
|
||||
|
||||
t.Views().Information().Content(Contains("Building patch"))
|
||||
|
||||
t.Common().SelectPatchOption(Contains("Move patch into new commit before the original commit"))
|
||||
|
||||
t.ExpectPopup().CommitMessagePanel().
|
||||
@@ -80,7 +87,6 @@ var MoveToNewCommitBefore = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
SelectPreviousItem().
|
||||
PressEnter()
|
||||
|
||||
// the original commit has no more files in it
|
||||
t.Views().CommitFiles().
|
||||
IsFocused().
|
||||
Lines(
|
||||
@@ -414,10 +414,14 @@ var tests = []*components.IntegrationTest{
|
||||
main_view.MovePartOfAdjacentAddedLinesToIndex,
|
||||
main_view.MovePartialPatchToIndex,
|
||||
main_view.MovePatchFromAddedFileToIndexWithConflict,
|
||||
main_view.MovePatchToEarlierCommit,
|
||||
main_view.MovePatchToIndex,
|
||||
main_view.MovePatchToIndexWithConflict,
|
||||
main_view.MovePatchToIndexWithCustomDiffConfig,
|
||||
main_view.MovePatchToIndexWithModifiedFile,
|
||||
main_view.MovePatchToLaterCommit,
|
||||
main_view.MovePatchToNewCommit,
|
||||
main_view.MovePatchToNewCommitBefore,
|
||||
main_view.NavigateByHunkAndFile,
|
||||
main_view.NoSelectionOverABinaryDiff,
|
||||
main_view.NoSelectionOverACommitLog,
|
||||
@@ -482,12 +486,8 @@ var tests = []*components.IntegrationTest{
|
||||
patch_building.CopyRenamedFileDiff,
|
||||
patch_building.DiscardLinesFromCommit,
|
||||
patch_building.EditLineInPatchBuildingPanel,
|
||||
patch_building.MoveToEarlierCommit,
|
||||
patch_building.MoveToEarlierCommitFromAddedFile,
|
||||
patch_building.MoveToLaterCommit,
|
||||
patch_building.MoveToLaterCommitPartialHunk,
|
||||
patch_building.MoveToNewCommit,
|
||||
patch_building.MoveToNewCommitBefore,
|
||||
patch_building.MoveToNewCommitFromAddedFile,
|
||||
patch_building.MoveToNewCommitFromDeletedFile,
|
||||
patch_building.MoveToNewCommitInLastCommitOfStackedBranch,
|
||||
|
||||
Reference in New Issue
Block a user