2023-02-25 13:08:45 +11:00
|
|
|
package patch_building
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/jesseduffield/lazygit/pkg/config"
|
|
|
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
|
|
|
)
|
|
|
|
|
|
|
|
var MoveToNewCommit = NewIntegrationTest(NewIntegrationTestArgs{
|
|
|
|
Description: "Move a patch from a commit to a new commit",
|
2023-05-21 17:00:29 +10:00
|
|
|
ExtraCmdArgs: []string{},
|
2023-02-25 13:08:45 +11:00
|
|
|
Skip: false,
|
|
|
|
SetupConfig: func(config *config.AppConfig) {},
|
|
|
|
SetupRepo: func(shell *Shell) {
|
2023-03-18 08:17:47 +01:00
|
|
|
shell.CreateDir("dir")
|
|
|
|
shell.CreateFileAndAdd("dir/file1", "file1 content")
|
|
|
|
shell.CreateFileAndAdd("dir/file2", "file2 content")
|
2023-02-25 13:08:45 +11:00
|
|
|
shell.Commit("first commit")
|
|
|
|
|
2023-03-18 08:17:47 +01:00
|
|
|
shell.UpdateFileAndAdd("dir/file1", "file1 content with old changes")
|
|
|
|
shell.DeleteFileAndAdd("dir/file2")
|
|
|
|
shell.CreateFileAndAdd("dir/file3", "file3 content")
|
|
|
|
shell.Commit("commit to move from")
|
2023-02-25 13:08:45 +11:00
|
|
|
|
2023-03-18 08:17:47 +01:00
|
|
|
shell.UpdateFileAndAdd("dir/file1", "file1 content with new changes")
|
2023-02-25 13:08:45 +11:00
|
|
|
shell.Commit("third commit")
|
|
|
|
},
|
|
|
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
|
|
|
t.Views().Commits().
|
|
|
|
Focus().
|
|
|
|
Lines(
|
|
|
|
Contains("third commit").IsSelected(),
|
2023-03-18 08:17:47 +01:00
|
|
|
Contains("commit to move from"),
|
2023-02-25 13:08:45 +11:00
|
|
|
Contains("first commit"),
|
|
|
|
).
|
|
|
|
SelectNextItem().
|
|
|
|
PressEnter()
|
|
|
|
|
|
|
|
t.Views().CommitFiles().
|
|
|
|
IsFocused().
|
|
|
|
Lines(
|
2023-03-18 08:17:47 +01:00
|
|
|
Contains("dir").IsSelected(),
|
|
|
|
Contains(" M file1"),
|
|
|
|
Contains(" D file2"),
|
|
|
|
Contains(" A file3"),
|
2023-02-25 13:08:45 +11:00
|
|
|
).
|
2023-03-18 08:17:47 +01:00
|
|
|
PressPrimaryAction().
|
|
|
|
PressEscape()
|
2023-02-25 13:08:45 +11:00
|
|
|
|
2023-05-25 21:11:51 +10:00
|
|
|
t.Views().Information().Content(Contains("Building patch"))
|
2023-02-25 13:08:45 +11:00
|
|
|
|
2023-05-25 21:11:51 +10:00
|
|
|
t.Common().SelectPatchOption(Contains("Move patch into new commit"))
|
2023-02-25 13:08:45 +11:00
|
|
|
|
2023-03-18 08:17:47 +01:00
|
|
|
t.Views().Commits().
|
|
|
|
IsFocused().
|
|
|
|
Lines(
|
|
|
|
Contains("third commit"),
|
|
|
|
Contains(`Split from "commit to move from"`).IsSelected(),
|
|
|
|
Contains("commit to move from"),
|
|
|
|
Contains("first commit"),
|
|
|
|
).
|
|
|
|
PressEnter()
|
|
|
|
|
2023-02-25 13:08:45 +11:00
|
|
|
t.Views().CommitFiles().
|
|
|
|
IsFocused().
|
|
|
|
Lines(
|
2023-03-18 08:17:47 +01:00
|
|
|
Contains("dir").IsSelected(),
|
|
|
|
Contains(" M file1"),
|
|
|
|
Contains(" D file2"),
|
|
|
|
Contains(" A file3"),
|
2023-02-25 13:08:45 +11:00
|
|
|
).
|
|
|
|
PressEscape()
|
|
|
|
|
|
|
|
t.Views().Commits().
|
|
|
|
IsFocused().
|
|
|
|
Lines(
|
|
|
|
Contains("third commit"),
|
2023-03-18 08:17:47 +01:00
|
|
|
Contains(`Split from "commit to move from"`).IsSelected(),
|
|
|
|
Contains("commit to move from"),
|
2023-02-25 13:08:45 +11:00
|
|
|
Contains("first commit"),
|
|
|
|
).
|
|
|
|
SelectNextItem().
|
|
|
|
PressEnter()
|
|
|
|
|
|
|
|
// the original commit has no more files in it
|
|
|
|
t.Views().CommitFiles().
|
|
|
|
IsFocused().
|
|
|
|
Lines(
|
|
|
|
Contains("(none)"),
|
|
|
|
)
|
|
|
|
},
|
|
|
|
})
|