summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-08-04 08:38:15 +1000
committerJesse Duffield <jessedduffield@gmail.com>2023-08-04 08:38:15 +1000
commit096628e3662bce97e312a7a9596a9ed86b141b8f (patch)
tree39eaa00000ae6e8628aed70c046ac3abddd5d3c3 /pkg
parentb432fb5efef09f43e3dfa94b5ae5e4fd6aca63bc (diff)
Add custom command demo
Diffstat (limited to 'pkg')
-rw-r--r--pkg/integration/tests/demo/custom_command.go78
-rw-r--r--pkg/integration/tests/test_list.go1
2 files changed, 79 insertions, 0 deletions
diff --git a/pkg/integration/tests/demo/custom_command.go b/pkg/integration/tests/demo/custom_command.go
new file mode 100644
index 000000000..46b6b515e
--- /dev/null
+++ b/pkg/integration/tests/demo/custom_command.go
@@ -0,0 +1,78 @@
+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) {
+ // No idea why I had to use version 2: it should be using my own computer's
+ // font and the one iterm uses is version 3.
+ cfg.UserConfig.Gui.NerdFontsVersion = "2"
+
+ 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()
+ })
+ },
+})
diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go
index c1e41bc91..1b1fa876d 100644
--- a/pkg/integration/tests/test_list.go
+++ b/pkg/integration/tests/test_list.go
@@ -93,6 +93,7 @@ var tests = []*components.IntegrationTest{
demo.Bisect,
demo.CherryPick,
demo.CommitAndPush,
+ demo.CustomCommand,
demo.Filter,
demo.InteractiveRebase,
demo.NukeWorkingTree,