Add a test showing that removing a submodule in a linked worktree deletes the wrong git dir

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Stefan Haller
2026-11-07 23:44:58 +01:00
co-authored by Claude Opus 5.5
parent 63ab89fff4
commit 58fcd14a99
2 changed files with 53 additions and 0 deletions
@@ -0,0 +1,52 @@
package submodule
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var RemoveInLinkedWorktree = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Remove a submodule in a linked worktree",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.EmptyCommit("first commit")
shell.CloneIntoSubmodule("my_submodule_name", "my_submodule_path")
shell.GitAddAll()
shell.Commit("add submodule")
shell.AddWorktree("HEAD", "../linked-worktree", "mybranch")
shell.Chdir("../linked-worktree")
shell.RunCommand([]string{"git", "submodule", "update", "--init"})
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
// Git keeps the git dirs of submodules separately for each worktree
mainGitDirSubmodulePath := "../repo/.git/modules/my_submodule_name"
linkedGitDirSubmodulePath := "../repo/.git/worktrees/linked-worktree/modules/my_submodule_name"
t.FileSystem().
PathPresent(mainGitDirSubmodulePath).
PathPresent(linkedGitDirSubmodulePath)
t.Views().Submodules().Focus().
Lines(
Contains("my_submodule_name").IsSelected(),
).
Press(keys.Universal.Remove).
Tap(func() {
t.ExpectPopup().Confirmation().
Title(Equals("Remove submodule")).
Content(Equals("Are you sure you want to remove submodule 'my_submodule_name' and its corresponding directory? This is irreversible.")).
Confirm()
}).
IsEmpty()
t.FileSystem().
/* EXPECTED:
PathPresent(mainGitDirSubmodulePath).
PathNotPresent(linkedGitDirSubmodulePath)
ACTUAL: */
PathNotPresent(mainGitDirSubmodulePath).
PathPresent(linkedGitDirSubmodulePath)
},
})
+1
View File
@@ -579,6 +579,7 @@ var tests = []*components.IntegrationTest{
submodule.EnterFromDotfileBareRepo,
submodule.EnterNested,
submodule.Remove,
submodule.RemoveInLinkedWorktree,
submodule.RemoveNested,
submodule.Reset,
submodule.ResetFolder,