1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
package demo
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var customCommandContent = `
customCommands:
- key: 'a'
command: 'git checkout {{.Form.Branch}}'
context: 'localBranches'
prompts:
- type: 'input'
title: 'Enter a branch name to checkout:'
key: 'Branch'
suggestions:
preset: 'branches'
`
var CustomCommand = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Invoke a custom command",
ExtraCmdArgs: []string{},
Skip: false,
IsDemo: true,
SetupConfig: func(cfg *config.AppConfig) {
setDefaultDemoConfig(cfg)
cfg.UserConfig.CustomCommands = []config.CustomCommand{
{
Key: "a",
Context: "localBranches",
Command: `git checkout {{.Form.Branch}}`,
Prompts: []config.CustomCommandPrompt{
{
Key: "Branch",
Type: "input",
Title: "Enter a branch name to checkout",
Suggestions: config.CustomCommandSuggestions{
Preset: "branches",
},
},
},
},
}
},
SetupRepo: func(shell *Shell) {
shell.CreateNCommitsWithRandomMessages(30)
shell.NewBranch("feature/user-authentication")
shell.NewBranch("feature/payment-processing")
shell.NewBranch("feature/search-functionality")
shell.NewBranch("feature/mobile-responsive")
shell.EmptyCommit("Make mobile response")
shell.NewBranch("bugfix/fix-login-issue")
shell.HardReset("HEAD~1")
shell.NewBranch("bugfix/fix-crash-bug")
shell.CreateFile("custom_commands_example.yml", customCommandContent)
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.SetCaptionPrefix("Invoke a custom command")
t.Wait(1500)
t.Views().Branches().
Focus().
Wait(500).
Press("a").
Tap(func() {
t.Wait(500)
t.ExpectPopup().Prompt().
Title(Equals("Enter a branch name to checkout")).
Type("mobile").
ConfirmFirstSuggestion()
})
},
})
|