1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-03-25 22:01:14 +02:00

63 lines
1.8 KiB
Go
Raw Normal View History

2022-09-10 17:00:40 +02:00
package interactive_rebase
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
2022-09-17 11:58:24 -07:00
var (
postMergeFileContent = "post merge file content"
postMergeFilename = "post-merge-file"
)
2022-09-10 17:00:40 +02:00
var AmendMerge = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Amends a staged file to a merge commit.",
ExtraCmdArgs: []string{},
2022-09-10 17:00:40 +02:00
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.
NewBranch("development-branch").
2022-09-17 11:58:24 -07:00
CreateFileAndAdd("initial-file", "initial file content").
2022-09-10 17:00:40 +02:00
Commit("initial commit").
NewBranch("feature-branch"). // it's also checked out automatically
CreateFileAndAdd("new-feature-file", "new content").
Commit("new feature commit").
2022-09-17 11:58:24 -07:00
Checkout("development-branch").
2022-09-10 17:00:40 +02:00
Merge("feature-branch").
2022-09-17 11:58:24 -07:00
CreateFileAndAdd(postMergeFilename, postMergeFileContent)
2022-09-10 17:00:40 +02:00
},
2022-12-27 21:47:37 +11:00
Run: func(t *TestDriver, keys config.KeybindingConfig) {
2022-09-17 11:58:24 -07:00
mergeCommitMessage := "Merge branch 'feature-branch' into development-branch"
2022-12-27 22:52:20 +11:00
t.Views().Commits().
Lines(
Contains(mergeCommitMessage),
Contains("new feature commit"),
Contains("initial commit"),
)
2022-12-27 21:35:36 +11:00
t.Views().Commits().
Focus().
Press(keys.Commits.AmendToCommit)
2022-09-17 11:58:24 -07:00
2022-12-28 11:00:22 +11:00
t.ExpectPopup().Confirmation().
Title(Equals("Amend commit")).
Content(Contains("Are you sure you want to amend this commit with your staged files?")).
Confirm()
2022-09-10 17:00:40 +02:00
2022-09-17 11:58:24 -07:00
// assuring we haven't added a brand new commit
2022-12-27 22:52:20 +11:00
t.Views().Commits().
Lines(
Contains(mergeCommitMessage),
Contains("new feature commit"),
Contains("initial commit"),
)
2022-09-17 11:58:24 -07:00
// assuring the post-merge file shows up in the merge commit.
2022-12-27 21:35:36 +11:00
t.Views().Main().
2022-12-26 11:12:56 +11:00
Content(Contains(postMergeFilename)).
Content(Contains("++" + postMergeFileContent))
2022-09-10 17:00:40 +02:00
},
})