From b3060065d9a776c755903a1297ab3954c01853a8 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Mon, 24 Jul 2023 17:16:59 +1000 Subject: Support fastforwarding worktree --- .../tests/worktree/fast_forward_worktree_branch.go | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 pkg/integration/tests/worktree/fast_forward_worktree_branch.go (limited to 'pkg/integration/tests/worktree') diff --git a/pkg/integration/tests/worktree/fast_forward_worktree_branch.go b/pkg/integration/tests/worktree/fast_forward_worktree_branch.go new file mode 100644 index 000000000..99d32f40a --- /dev/null +++ b/pkg/integration/tests/worktree/fast_forward_worktree_branch.go @@ -0,0 +1,52 @@ +package worktree + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var FastForwardWorktreeBranch = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Fast-forward a linked worktree branch from another worktree", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + // both main and linked worktree will have changed to fast-foward + shell.NewBranch("mybranch") + shell.CreateFileAndAdd("README.md", "hello world") + shell.Commit("initial commit") + shell.EmptyCommit("two") + shell.EmptyCommit("three") + shell.NewBranch("newbranch") + + shell.CloneIntoRemote("origin") + shell.SetBranchUpstream("mybranch", "origin/mybranch") + shell.SetBranchUpstream("newbranch", "origin/newbranch") + + // remove the 'three' commit so that we have something to pull from the remote + shell.HardReset("HEAD^") + shell.Checkout("mybranch") + shell.HardReset("HEAD^") + + shell.AddWorktreeCheckout("newbranch", "../linked-worktree") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Branches(). + Focus(). + Lines( + Contains("mybranch").Contains("↓1").IsSelected(), + Contains("newbranch (worktree)").Contains("↓1"), + ). + Press(keys.Branches.FastForward). + Lines( + Contains("mybranch").Contains("✓").IsSelected(), + Contains("newbranch (worktree)").Contains("↓1"), + ). + NavigateToLine(Contains("newbranch (worktree)")). + Press(keys.Branches.FastForward). + Lines( + Contains("mybranch").Contains("✓"), + Contains("newbranch (worktree)").Contains("✓").IsSelected(), + ) + }, +}) -- cgit v1.2.3