Skip to content

Commit 59fdc9c

Browse files
committed
Add test demonstrating the problem
For a worktree that contains submodules, trying to delete it shows an error and doesn't offer to force-remove it.
1 parent 1fd771f commit 59fdc9c

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

pkg/integration/tests/test_list.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ var tests = []*components.IntegrationTest{
455455
worktree.FastForwardWorktreeBranch,
456456
worktree.FastForwardWorktreeBranchShouldNotPolluteCurrentWorktree,
457457
worktree.ForceRemoveWorktree,
458+
worktree.ForceRemoveWorktreeWithSubmodules,
458459
worktree.RemoveWorktreeFromBranch,
459460
worktree.ResetWindowTabs,
460461
worktree.SymlinkIntoRepoSubdir,
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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 ForceRemoveWorktreeWithSubmodules = NewIntegrationTest(NewIntegrationTestArgs{
9+
Description: "Force remove a worktree that contains submodules",
10+
ExtraCmdArgs: []string{},
11+
Skip: false,
12+
SetupConfig: func(config *config.AppConfig) {},
13+
SetupRepo: func(shell *Shell) {
14+
shell.NewBranch("mybranch")
15+
shell.CreateFileAndAdd("README.md", "hello world")
16+
shell.Commit("initial commit")
17+
shell.CloneIntoSubmodule("submodule", "submodule")
18+
shell.Commit("Add submodule")
19+
shell.AddWorktree("mybranch", "../linked-worktree", "newbranch")
20+
shell.RunCommand([]string{"git", "-C", "../linked-worktree", "submodule", "update", "--init"})
21+
},
22+
Run: func(t *TestDriver, keys config.KeybindingConfig) {
23+
t.Views().Worktrees().
24+
Focus().
25+
Lines(
26+
Contains("repo (main)").IsSelected(),
27+
Contains("linked-worktree"),
28+
).
29+
NavigateToLine(Contains("linked-worktree")).
30+
Press(keys.Universal.Remove).
31+
Tap(func() {
32+
t.ExpectPopup().Confirmation().
33+
Title(Equals("Remove worktree")).
34+
Content(Equals("Are you sure you want to remove worktree 'linked-worktree'?")).
35+
Confirm()
36+
37+
/* EXPECTED:
38+
t.ExpectPopup().Confirmation().
39+
Title(Equals("Remove worktree")).
40+
Content(Equals("'linked-worktree' contains modified or untracked files, or submodules (or all of these). Are you sure you want to remove it?")).
41+
Confirm()
42+
ACTUAL: */
43+
t.ExpectPopup().Alert().
44+
Title(Equals("Error")).
45+
Content(Equals("fatal: working trees containing submodules cannot be moved or removed")).
46+
Confirm()
47+
}).
48+
/* EXPECTED:
49+
Lines(
50+
Contains("repo (main)").IsSelected(),
51+
)
52+
ACTUAL: */
53+
Lines(
54+
Contains("repo (main)"),
55+
Contains("linked-worktree").IsSelected(),
56+
)
57+
},
58+
})

0 commit comments

Comments
 (0)