mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-06 10:42:32 +03:00
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
63 lines
1.6 KiB
Go
63 lines
1.6 KiB
Go
package file
|
|
|
|
import (
|
|
"github.com/jesseduffield/lazygit/pkg/config"
|
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
|
)
|
|
|
|
var preCommitHook = `#!/bin/bash
|
|
|
|
if [[ -f bad ]]; then
|
|
exit 1
|
|
fi
|
|
`
|
|
|
|
var RememberCommitMessageAfterFail = NewIntegrationTest(NewIntegrationTestArgs{
|
|
Description: "Verify that the commit message is remembered after a failed attempt at committing",
|
|
ExtraCmdArgs: []string{},
|
|
Skip: false,
|
|
SetupConfig: func(config *config.AppConfig) {
|
|
},
|
|
SetupRepo: func(shell *Shell) {
|
|
shell.CreateFile(".git/hooks/pre-commit", preCommitHook)
|
|
shell.MakeExecutable(".git/hooks/pre-commit")
|
|
|
|
shell.CreateFileAndAdd("one", "one")
|
|
|
|
// the presence of this file will cause the pre-commit hook to fail
|
|
shell.CreateFile("bad", "bad")
|
|
},
|
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
|
t.Views().Files().
|
|
IsFocused().
|
|
Lines(
|
|
Contains("bad"),
|
|
Contains("one"),
|
|
).
|
|
Press(keys.Files.CommitChanges).
|
|
Tap(func() {
|
|
t.ExpectPopup().CommitMessagePanel().Type("my message").Confirm()
|
|
|
|
t.ExpectPopup().Alert().Title(Equals("Error")).Content(Contains("Git command failed")).Confirm()
|
|
}).
|
|
Press(keys.Universal.Remove). // remove file that triggers pre-commit hook to fail
|
|
Tap(func() {
|
|
t.ExpectPopup().Menu().Title(Equals("bad")).Select(Contains("discard all changes")).Confirm()
|
|
}).
|
|
Lines(
|
|
Contains("one"),
|
|
).
|
|
Press(keys.Files.CommitChanges).
|
|
Tap(func() {
|
|
t.ExpectPopup().CommitMessagePanel().
|
|
InitialText(Equals("my message")). // it remembered the commit message
|
|
Confirm()
|
|
|
|
t.Views().Commits().
|
|
Lines(
|
|
Contains("my message"),
|
|
)
|
|
})
|
|
},
|
|
})
|