Add a test showing that nuking the working tree can stash changes in other repositories

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Stefan Haller
2026-11-07 23:59:32 +01:00
co-authored by Claude Opus 5.5
parent bcbc5ebd6d
commit a159e24919
2 changed files with 76 additions and 0 deletions
@@ -0,0 +1,75 @@
package submodule
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var IgnoreSuspiciousPath = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Ignore a submodule whose path in .gitmodules leads outside the repository",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
// Two unrelated repos next to ours, each with an uncommitted change
for _, otherRepo := range []string{"other_repo", "linked_repo"} {
shell.Chdir("..")
shell.CreateDir(otherRepo)
shell.Chdir(otherRepo)
shell.Init()
shell.CreateFileAndAdd("file", "original")
shell.Commit("initial commit")
shell.UpdateFile("file", "modified")
shell.Chdir("../repo")
}
shell.EmptyCommit("first commit")
shell.RunCommand([]string{"ln", "-s", "../linked_repo", "link"})
shell.GitAdd("link")
shell.CreateFileAndAdd(".gitmodules", `[submodule "other"]
path = ../other_repo
url = ../other_repo
[submodule "linked"]
path = link
url = ../linked_repo
`)
shell.Commit("add submodules")
shell.CreateFile("untracked", "content")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Submodules().
/* EXPECTED:
IsEmpty()
ACTUAL: */
Lines(
Contains("other"),
Contains("linked"),
)
t.Views().Files().Focus().
Lines(
Contains("untracked"),
).
Press(keys.Files.ViewResetOptions).
Tap(func() {
t.ExpectPopup().Menu().
Title(Equals("")).
Select(Contains("Nuke working tree")).
Confirm()
t.ExpectPopup().Confirmation().
Title(Equals("Nuke working tree")).
Content(AnyString()).
Confirm()
}).
IsEmpty()
t.FileSystem().
/* EXPECTED:
FileContent("../other_repo/file", Equals("modified")).
FileContent("../linked_repo/file", Equals("modified"))
ACTUAL: */
FileContent("../other_repo/file", Equals("original")).
FileContent("../linked_repo/file", Equals("original"))
},
})
+1
View File
@@ -579,6 +579,7 @@ var tests = []*components.IntegrationTest{
submodule.EnterFromDotfileBareRepo,
submodule.EnterNested,
submodule.IgnoreSuspiciousName,
submodule.IgnoreSuspiciousPath,
submodule.Remove,
submodule.RemoveInLinkedWorktree,
submodule.RemoveNested,