1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-02-05 13:24:54 +02:00

51 lines
1.6 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: "",
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
},
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
assert.CommitCount(3)
2022-12-26 16:49:54 +11:00
input.SwitchToCommitsView()
2022-09-10 17:00:40 +02:00
2022-09-17 11:58:24 -07:00
mergeCommitMessage := "Merge branch 'feature-branch' into development-branch"
assert.HeadCommitMessage(Contains(mergeCommitMessage))
2022-09-17 11:58:24 -07:00
input.Press(keys.Commits.AmendToCommit)
input.AcceptConfirmation(Equals("Amend Commit"), Contains("Are you sure you want to amend this commit with your staged files?"))
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-09-10 17:00:40 +02:00
assert.CommitCount(3)
assert.HeadCommitMessage(Contains(mergeCommitMessage))
2022-09-17 11:58:24 -07:00
// assuring the post-merge file shows up in the merge commit.
2022-12-26 11:12:56 +11:00
assert.MainView().
Content(Contains(postMergeFilename)).
Content(Contains("++" + postMergeFileContent))
2022-09-10 17:00:40 +02:00
},
})