mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-11-13 16:23:32 -04:00
Add a test showing that removing a submodule can delete a directory outside the repository
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
aa034b1b5e
commit
0c46c6261f
@@ -0,0 +1,54 @@
|
||||
package submodule
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var IgnoreSuspiciousName = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Ignore a submodule whose name in .gitmodules would put its git dir outside the repository",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.CreateFile("../victim/file", "content")
|
||||
|
||||
shell.EmptyCommit("first commit")
|
||||
shell.CloneIntoSubmodule("my_submodule_name", "my_submodule_path")
|
||||
shell.GitAddAll()
|
||||
shell.Commit("add submodule")
|
||||
|
||||
// The git dir of a submodule is .git/modules/<name>, so this name
|
||||
// points at the victim directory next to the repository
|
||||
shell.UpdateFileAndAdd(".gitmodules", `[submodule "../../../victim"]
|
||||
path = my_submodule_path
|
||||
url = ../my_submodule_name
|
||||
`)
|
||||
shell.Commit("rename submodule")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Submodules().Focus().
|
||||
/* EXPECTED:
|
||||
IsEmpty()
|
||||
ACTUAL: */
|
||||
Lines(
|
||||
Contains("../../../victim").IsSelected(),
|
||||
).
|
||||
Press(keys.Universal.Remove).
|
||||
Tap(func() {
|
||||
t.ExpectPopup().Confirmation().
|
||||
Title(Equals("Remove submodule")).
|
||||
Content(Equals("Are you sure you want to remove submodule '../../../victim' and its corresponding directory? This is irreversible.")).
|
||||
Confirm()
|
||||
}).
|
||||
Lines(
|
||||
Contains("../../../victim").IsSelected(),
|
||||
)
|
||||
|
||||
t.FileSystem().
|
||||
/* EXPECTED:
|
||||
PathPresent("../victim/file")
|
||||
ACTUAL: */
|
||||
PathNotPresent("../victim/file")
|
||||
},
|
||||
})
|
||||
@@ -578,6 +578,7 @@ var tests = []*components.IntegrationTest{
|
||||
submodule.Enter,
|
||||
submodule.EnterFromDotfileBareRepo,
|
||||
submodule.EnterNested,
|
||||
submodule.IgnoreSuspiciousName,
|
||||
submodule.Remove,
|
||||
submodule.RemoveInLinkedWorktree,
|
||||
submodule.RemoveNested,
|
||||
|
||||
Reference in New Issue
Block a user