summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-08-04 08:54:13 +1000
committerJesse Duffield <jessedduffield@gmail.com>2023-08-04 09:14:58 +1000
commit996ad5bf263a253a527897accf53e3d198c0345c (patch)
tree64f1b60122b4b775f6edf6156120ef64e088f633
parent096628e3662bce97e312a7a9596a9ed86b141b8f (diff)
Add worktree demo
-rw-r--r--README.md8
-rw-r--r--pkg/integration/tests/demo/worktree_create_from_branches.go59
-rw-r--r--pkg/integration/tests/test_list.go1
3 files changed, 68 insertions, 0 deletions
diff --git a/README.md b/README.md
index 49116c065..946b7272f 100644
--- a/README.md
+++ b/README.md
@@ -113,6 +113,14 @@ Lazygit has a very flexible [custom command system](docs/Custom_Command_Keybindi
![custom_command](../assets/demo/custom_command-compressed.gif)
+### Worktrees
+
+You can create worktrees to have multiple branches going at once without the need for stashing or creating WIP commits when switching between them. Press `w` in the branches view to create a worktree from the selected branch and switch to it.
+
+![worktree_create_from_branches](../assets/demo/worktree_create_from_branches-compressed.gif)
+
+### Rebase magic (custom patches)
+
## Tutorials
[<img src="https://i.imgur.com/sVEktDn.png">](https://youtu.be/CPLdltN7wgE)
diff --git a/pkg/integration/tests/demo/worktree_create_from_branches.go b/pkg/integration/tests/demo/worktree_create_from_branches.go
new file mode 100644
index 000000000..d25b531d2
--- /dev/null
+++ b/pkg/integration/tests/demo/worktree_create_from_branches.go
@@ -0,0 +1,59 @@
+package demo
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var WorktreeCreateFromBranches = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Create a worktree from the branches view",
+ 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"
+ },
+ SetupRepo: func(shell *Shell) {
+ shell.CreateNCommitsWithRandomMessages(30)
+ shell.NewBranch("feature/user-authentication")
+ shell.EmptyCommit("Add user authentication feature")
+ shell.EmptyCommit("Fix local session storage")
+ shell.CreateFile("src/authentication.go", "package main")
+ shell.CreateFile("src/shims.go", "package main")
+ shell.CreateFile("src/session.go", "package main")
+ shell.EmptyCommit("Stop using shims")
+ shell.UpdateFile("src/authentication.go", "package authentication")
+ shell.UpdateFileAndAdd("src/shims.go", "// removing for now")
+ shell.UpdateFile("src/session.go", "package session")
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.SetCaptionPrefix("Create a worktree from a branch")
+ t.Wait(1000)
+
+ t.Views().Branches().
+ Focus().
+ NavigateToLine(Contains("master")).
+ Wait(500).
+ Press(keys.Worktrees.ViewWorktreeOptions).
+ Tap(func() {
+ t.Wait(500)
+
+ t.ExpectPopup().Menu().
+ Title(Equals("Worktree")).
+ Select(Contains("Create worktree from master").DoesNotContain("detached")).
+ Confirm()
+
+ t.ExpectPopup().Prompt().
+ Title(Equals("New worktree path")).
+ Type("../hotfix").
+ Confirm()
+
+ t.ExpectPopup().Prompt().
+ Title(Contains("New branch name")).
+ Type("hotfix/db-on-fire").
+ Confirm()
+ })
+ },
+})
diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go
index 1b1fa876d..c5e94c532 100644
--- a/pkg/integration/tests/test_list.go
+++ b/pkg/integration/tests/test_list.go
@@ -99,6 +99,7 @@ var tests = []*components.IntegrationTest{
demo.NukeWorkingTree,
demo.StageLines,
demo.Undo,
+ demo.WorktreeCreateFromBranches,
diff.Diff,
diff.DiffAndApplyPatch,
diff.DiffCommits,