diff --git a/pkg/integration/tests/submodule/ignore_suspicious_path.go b/pkg/integration/tests/submodule/ignore_suspicious_path.go new file mode 100644 index 000000000..0f0d0e953 --- /dev/null +++ b/pkg/integration/tests/submodule/ignore_suspicious_path.go @@ -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")) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index ae54d0f6e..97a225f06 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -579,6 +579,7 @@ var tests = []*components.IntegrationTest{ submodule.EnterFromDotfileBareRepo, submodule.EnterNested, submodule.IgnoreSuspiciousName, + submodule.IgnoreSuspiciousPath, submodule.Remove, submodule.RemoveInLinkedWorktree, submodule.RemoveNested,