1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-11-29 22:48:24 +02:00

Don't add custom command to history if it starts with space

Add tests for custom command with leading space
This commit is contained in:
Luka Markušić
2023-03-10 10:31:30 +01:00
committed by Jesse Duffield
parent caedf57484
commit 2b4ac986a2
5 changed files with 91 additions and 6 deletions

View File

@@ -0,0 +1,35 @@
package custom_commands
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var BasicCmdAtRuntime = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Using a custom command provided at runtime to create a new file",
ExtraCmdArgs: "",
Skip: false,
SetupRepo: func(shell *Shell) {
shell.EmptyCommit("blah")
},
SetupConfig: func(cfg *config.AppConfig) {},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Files().
IsEmpty().
IsFocused().
Press(keys.Universal.ExecuteCustomCommand)
t.ExpectPopup().Prompt().
Title(Equals("Custom Command:")).
Type("touch file.txt").
Confirm()
t.GlobalPress(keys.Files.RefreshFiles)
t.Views().Files().
IsFocused().
Lines(
Contains("file.txt"),
)
},
})

View File

@@ -0,0 +1,38 @@
package custom_commands
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var OmitFromHistory = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Omitting a runtime custom command from history if it begins with space",
ExtraCmdArgs: "",
Skip: false,
SetupRepo: func(shell *Shell) {
shell.EmptyCommit("blah")
},
SetupConfig: func(cfg *config.AppConfig) {},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.GlobalPress(keys.Universal.ExecuteCustomCommand)
t.ExpectPopup().Prompt().
Title(Equals("Custom Command:")).
Type("echo aubergine").
Confirm()
t.GlobalPress(keys.Universal.ExecuteCustomCommand)
t.ExpectPopup().Prompt().
Title(Equals("Custom Command:")).
SuggestionLines(Contains("aubergine")).
SuggestionLines(DoesNotContain("tangerine")).
Type(" echo tangerine").
Confirm()
t.GlobalPress(keys.Universal.ExecuteCustomCommand)
t.ExpectPopup().Prompt().
Title(Equals("Custom Command:")).
SuggestionLines(Contains("aubergine")).
SuggestionLines(DoesNotContain("tangerine")).
Cancel()
},
})

View File

@@ -5,7 +5,7 @@ import (
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var Basic = NewIntegrationTest(NewIntegrationTestArgs{
var BasicCmdFromConfig = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Using a custom command to create a new file",
ExtraCmdArgs: "",
Skip: false,