1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-03-23 21:51:07 +02:00
Jesse Duffield 63dc07fded Construct arg vector manually rather than parse string
By constructing an arg vector manually, we no longer need to quote arguments

Mandate that args must be passed when building a command

Now you need to provide an args array when building a command.
There are a handful of places where we need to deal with a string,
such as with user-defined custom commands, and for those we now require
that at the callsite they use str.ToArgv to do that. I don't want
to provide a method out of the box for it because I want to discourage its
use.

For some reason we were invoking a command through a shell when amending a
commit, and I don't believe we needed to do that as there was nothing user-
supplied about the command. So I've switched to using a regular command out-
side the shell there
2023-05-23 19:49:19 +10:00

63 lines
1.8 KiB
Go

package interactive_rebase
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var (
postMergeFileContent = "post merge file content"
postMergeFilename = "post-merge-file"
)
var AmendMerge = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Amends a staged file to a merge commit.",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.
NewBranch("development-branch").
CreateFileAndAdd("initial-file", "initial file content").
Commit("initial commit").
NewBranch("feature-branch"). // it's also checked out automatically
CreateFileAndAdd("new-feature-file", "new content").
Commit("new feature commit").
Checkout("development-branch").
Merge("feature-branch").
CreateFileAndAdd(postMergeFilename, postMergeFileContent)
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
mergeCommitMessage := "Merge branch 'feature-branch' into development-branch"
t.Views().Commits().
Lines(
Contains(mergeCommitMessage),
Contains("new feature commit"),
Contains("initial commit"),
)
t.Views().Commits().
Focus().
Press(keys.Commits.AmendToCommit)
t.ExpectPopup().Confirmation().
Title(Equals("Amend Last Commit")).
Content(Contains("Are you sure you want to amend last commit?")).
Confirm()
// assuring we haven't added a brand new commit
t.Views().Commits().
Lines(
Contains(mergeCommitMessage),
Contains("new feature commit"),
Contains("initial commit"),
)
// assuring the post-merge file shows up in the merge commit.
t.Views().Main().
Content(Contains(postMergeFilename)).
Content(Contains("++" + postMergeFileContent))
},
})