Skip to content

Commit dfeddca

Browse files
committed
Add integration test for worktree option in git command
1 parent b436736 commit dfeddca

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package worktree
2+
3+
import (
4+
"github.com/jesseduffield/lazygit/pkg/config"
5+
. "github.com/jesseduffield/lazygit/pkg/integration/components"
6+
)
7+
8+
var FastForwardWorktreeBranchNoPolluteCurrentWorktree = NewIntegrationTest(NewIntegrationTestArgs{
9+
Description: "Fast-forward a linked worktree branch from another worktree",
10+
ExtraCmdArgs: []string{},
11+
Skip: false,
12+
SetupConfig: func(config *config.AppConfig) {},
13+
SetupRepo: func(shell *Shell) {
14+
// both main and linked worktree will have changed to fast-forward
15+
shell.NewBranch("mybranch")
16+
shell.CreateFileAndAdd("README.md", "hello world")
17+
shell.Commit("initial commit")
18+
shell.EmptyCommit("two")
19+
shell.EmptyCommit("three")
20+
shell.NewBranch("newbranch")
21+
22+
shell.CloneIntoRemote("origin")
23+
shell.SetBranchUpstream("mybranch", "origin/mybranch")
24+
shell.SetBranchUpstream("newbranch", "origin/newbranch")
25+
26+
// remove the 'three' commit so that we have something to pull from the remote
27+
shell.HardReset("HEAD^")
28+
shell.Checkout("mybranch")
29+
shell.HardReset("HEAD^")
30+
31+
shell.AddWorktreeCheckout("newbranch", "../linked-worktree")
32+
},
33+
Run: func(t *TestDriver, keys config.KeybindingConfig) {
34+
t.Views().Branches().
35+
Focus().
36+
Lines(
37+
Contains("mybranch").Contains("↓1").IsSelected(),
38+
Contains("newbranch (worktree)").Contains("↓1"),
39+
).
40+
Press(keys.Branches.FastForward).
41+
Lines(
42+
Contains("mybranch").Contains("✓").IsSelected(),
43+
Contains("newbranch (worktree)").Contains("↓1"),
44+
).
45+
NavigateToLine(Contains("newbranch (worktree)")).
46+
Press(keys.Branches.FastForward).
47+
Lines(
48+
Contains("mybranch").Contains("✓"),
49+
Contains("newbranch (worktree)").Contains("✓").IsSelected(),
50+
)
51+
52+
// check the current worktree that it has no lines in the File changes pane
53+
t.Views().Files().
54+
Focus().
55+
LineCount(EqualsInt(0))
56+
},
57+
})

0 commit comments

Comments
 (0)