summaryrefslogtreecommitdiffstats
path: root/pkg/integration
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2024-02-04 22:42:58 +0100
committerStefan Haller <stefan@haller-berlin.de>2024-03-07 20:16:28 +0100
commit3b723282cbe98063523e22f9dd71000d20dc5e20 (patch)
tree26216cd44d46ea6fcd21313541d39292c2c1b17e /pkg/integration
parentdb4f12929ec242182e482ee5ab829d463cda6ea5 (diff)
Show all submodules recursively
Diffstat (limited to 'pkg/integration')
-rw-r--r--pkg/integration/tests/submodule/enter_nested.go52
-rw-r--r--pkg/integration/tests/submodule/remove_nested.go56
-rw-r--r--pkg/integration/tests/submodule/shared.go39
-rw-r--r--pkg/integration/tests/test_list.go2
4 files changed, 149 insertions, 0 deletions
diff --git a/pkg/integration/tests/submodule/enter_nested.go b/pkg/integration/tests/submodule/enter_nested.go
new file mode 100644
index 000000000..172dfbfae
--- /dev/null
+++ b/pkg/integration/tests/submodule/enter_nested.go
@@ -0,0 +1,52 @@
+package submodule
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var EnterNested = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Enter a nested submodule",
+ ExtraCmdArgs: []string{},
+ Skip: false,
+ SetupConfig: func(cfg *config.AppConfig) {},
+ SetupRepo: func(shell *Shell) {
+ setupNestedSubmodules(shell)
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.Views().Submodules().Focus().
+ Lines(
+ Equals("outerSubName").IsSelected(),
+ Equals(" - innerSubName"),
+ ).
+ Tap(func() {
+ t.Views().Main().ContainsLines(
+ Contains("Name: outerSubName"),
+ Contains("Path: modules/outerSubPath"),
+ Contains("Url: ../outerSubmodule"),
+ )
+ }).
+ SelectNextItem().
+ Tap(func() {
+ t.Views().Main().ContainsLines(
+ Contains("Name: outerSubName/innerSubName"),
+ Contains("Path: modules/outerSubPath/modules/innerSubPath"),
+ Contains("Url: ../innerSubmodule"),
+ )
+ }).
+ // enter the nested submodule
+ PressEnter()
+
+ if t.Git().Version().IsAtLeast(2, 22, 0) {
+ t.Views().Status().Content(Contains("innerSubPath(innerSubName)"))
+ } else {
+ t.Views().Status().Content(Contains("innerSubPath"))
+ }
+ t.Views().Commits().ContainsLines(
+ Contains("initial inner commit"),
+ )
+
+ t.Views().Files().PressEscape()
+ t.Views().Status().Content(Contains("repo"))
+ },
+})
diff --git a/pkg/integration/tests/submodule/remove_nested.go b/pkg/integration/tests/submodule/remove_nested.go
new file mode 100644
index 000000000..ae32c0907
--- /dev/null
+++ b/pkg/integration/tests/submodule/remove_nested.go
@@ -0,0 +1,56 @@
+package submodule
+
+import (
+ "path/filepath"
+
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var RemoveNested = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Remove a nested submodule",
+ ExtraCmdArgs: []string{},
+ Skip: false,
+ SetupConfig: func(config *config.AppConfig) {},
+ SetupRepo: func(shell *Shell) {
+ setupNestedSubmodules(shell)
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ gitDirSubmodulePath, _ := filepath.Abs(".git/modules/outerSubName/modules/innerSubName")
+ t.FileSystem().PathPresent(gitDirSubmodulePath)
+
+ t.Views().Submodules().Focus().
+ Lines(
+ Equals("outerSubName").IsSelected(),
+ Equals(" - innerSubName"),
+ ).
+ SelectNextItem().
+ Press(keys.Universal.Remove).
+ Tap(func() {
+ t.ExpectPopup().Confirmation().
+ Title(Equals("Remove submodule")).
+ Content(Equals("Are you sure you want to remove submodule 'outerSubName/innerSubName' and its corresponding directory? This is irreversible.")).
+ Confirm()
+ }).
+ Lines(
+ Equals("outerSubName").IsSelected(),
+ ).
+ Press(keys.Universal.GoInto)
+
+ t.Views().Files().IsFocused().
+ Lines(
+ Contains("modules").IsSelected(),
+ MatchesRegexp(`D.*innerSubPath`),
+ MatchesRegexp(`M.*\.gitmodules`),
+ ).
+ NavigateToLine(Contains(".gitmodules"))
+
+ t.Views().Main().Content(
+ Contains("-[submodule \"innerSubName\"]").
+ Contains("- path = modules/innerSubPath").
+ Contains("- url = ../innerSubmodule"),
+ )
+
+ t.FileSystem().PathNotPresent(gitDirSubmodulePath)
+ },
+})
diff --git a/pkg/integration/tests/submodule/shared.go b/pkg/integration/tests/submodule/shared.go
new file mode 100644
index 000000000..43e0144ab
--- /dev/null
+++ b/pkg/integration/tests/submodule/shared.go
@@ -0,0 +1,39 @@
+package submodule
+
+import (
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+func setupNestedSubmodules(shell *Shell) {
+ // we're going to have a directory structure like this:
+ // project
+ // - repo/modules/outerSubName/modules/innerSubName/
+ //
+ shell.CreateFileAndAdd("rootFile", "rootStuff")
+ shell.Commit("initial repo commit")
+
+ shell.Chdir("..")
+ shell.CreateDir("innerSubmodule")
+ shell.Chdir("innerSubmodule")
+ shell.Init()
+ shell.CreateFileAndAdd("inner", "inner")
+ shell.Commit("initial inner commit")
+
+ shell.Chdir("..")
+ shell.CreateDir("outerSubmodule")
+ shell.Chdir("outerSubmodule")
+ shell.Init()
+ shell.CreateFileAndAdd("outer", "outer")
+ shell.Commit("initial outer commit")
+ shell.CreateDir("modules")
+ // the git config (-c) parameter below is required
+ // to let git create a file-protocol/path submodule
+ shell.RunCommand([]string{"git", "-c", "protocol.file.allow=always", "submodule", "add", "--name", "innerSubName", "../innerSubmodule", "modules/innerSubPath"})
+ shell.Commit("add dependency as innerSubmodule")
+
+ shell.Chdir("../repo")
+ shell.CreateDir("modules")
+ shell.RunCommand([]string{"git", "-c", "protocol.file.allow=always", "submodule", "add", "--name", "outerSubName", "../outerSubmodule", "modules/outerSubPath"})
+ shell.Commit("add dependency as outerSubmodule")
+ shell.RunCommand([]string{"git", "-c", "protocol.file.allow=always", "submodule", "update", "--init", "--recursive"})
+}
diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go
index e26a0731f..531fce5d9 100644
--- a/pkg/integration/tests/test_list.go
+++ b/pkg/integration/tests/test_list.go
@@ -245,7 +245,9 @@ var tests = []*components.IntegrationTest{
stash.StashUnstaged,
submodule.Add,
submodule.Enter,
+ submodule.EnterNested,
submodule.Remove,
+ submodule.RemoveNested,
submodule.Reset,
sync.FetchPrune,
sync.FetchWhenSortedByDate,