summaryrefslogtreecommitdiffstats
path: root/pkg/integration/tests/submodule
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/integration/tests/submodule')
-rw-r--r--pkg/integration/tests/submodule/enter.go12
-rw-r--r--pkg/integration/tests/submodule/enter_nested.go52
-rw-r--r--pkg/integration/tests/submodule/remove.go17
-rw-r--r--pkg/integration/tests/submodule/remove_nested.go56
-rw-r--r--pkg/integration/tests/submodule/reset.go22
-rw-r--r--pkg/integration/tests/submodule/shared.go39
6 files changed, 178 insertions, 20 deletions
diff --git a/pkg/integration/tests/submodule/enter.go b/pkg/integration/tests/submodule/enter.go
index 7b055c2b6..29e983b7f 100644
--- a/pkg/integration/tests/submodule/enter.go
+++ b/pkg/integration/tests/submodule/enter.go
@@ -20,7 +20,7 @@ var Enter = NewIntegrationTest(NewIntegrationTestArgs{
},
SetupRepo: func(shell *Shell) {
shell.EmptyCommit("first commit")
- shell.CloneIntoSubmodule("my_submodule")
+ shell.CloneIntoSubmodule("my_submodule_name", "my_submodule_path")
shell.GitAddAll()
shell.Commit("add submodule")
},
@@ -29,14 +29,18 @@ var Enter = NewIntegrationTest(NewIntegrationTestArgs{
t.Views().Status().Content(Contains("repo"))
}
assertInSubmodule := func() {
- t.Views().Status().Content(Contains("my_submodule"))
+ if t.Git().Version().IsAtLeast(2, 22, 0) {
+ t.Views().Status().Content(Contains("my_submodule_path(my_submodule_name)"))
+ } else {
+ t.Views().Status().Content(Contains("my_submodule_path"))
+ }
}
assertInParentRepo()
t.Views().Submodules().Focus().
Lines(
- Contains("my_submodule").IsSelected(),
+ Contains("my_submodule_name").IsSelected(),
).
// enter the submodule
PressEnter()
@@ -60,7 +64,7 @@ var Enter = NewIntegrationTest(NewIntegrationTestArgs{
t.Views().Files().Focus().
Lines(
- MatchesRegexp(` M.*my_submodule \(submodule\)`).IsSelected(),
+ MatchesRegexp(` M.*my_submodule_path \(submodule\)`).IsSelected(),
).
Tap(func() {
// main view also shows the new commit when we're looking at the submodule within the files view
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.go b/pkg/integration/tests/submodule/remove.go
index 3d85d4d5c..22fb83f30 100644
--- a/pkg/integration/tests/submodule/remove.go
+++ b/pkg/integration/tests/submodule/remove.go
@@ -12,20 +12,23 @@ var Remove = NewIntegrationTest(NewIntegrationTestArgs{
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.EmptyCommit("first commit")
- shell.CloneIntoSubmodule("my_submodule")
+ shell.CloneIntoSubmodule("my_submodule_name", "my_submodule_path")
shell.GitAddAll()
shell.Commit("add submodule")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ gitDirSubmodulePath := ".git/modules/my_submodule_name"
+ t.FileSystem().PathPresent(gitDirSubmodulePath)
+
t.Views().Submodules().Focus().
Lines(
- Contains("my_submodule").IsSelected(),
+ 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' and its corresponding directory? This is irreversible.")).
+ Content(Equals("Are you sure you want to remove submodule 'my_submodule_name' and its corresponding directory? This is irreversible.")).
Confirm()
}).
IsEmpty()
@@ -33,13 +36,15 @@ var Remove = NewIntegrationTest(NewIntegrationTestArgs{
t.Views().Files().Focus().
Lines(
MatchesRegexp(`M.*\.gitmodules`).IsSelected(),
- MatchesRegexp(`D.*my_submodule`),
+ MatchesRegexp(`D.*my_submodule_path`),
)
t.Views().Main().Content(
- Contains("-[submodule \"my_submodule\"]").
- Contains("- path = my_submodule").
+ Contains("-[submodule \"my_submodule_name\"]").
+ Contains("- path = my_submodule_path").
Contains("- url = ../other_repo"),
)
+
+ t.FileSystem().PathNotPresent(gitDirSubmodulePath)
},
})
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/reset.go b/pkg/integration/tests/submodule/reset.go
index fba91bee8..a723561fc 100644
--- a/pkg/integration/tests/submodule/reset.go
+++ b/pkg/integration/tests/submodule/reset.go
@@ -20,7 +20,7 @@ var Reset = NewIntegrationTest(NewIntegrationTestArgs{
},
SetupRepo: func(shell *Shell) {
shell.EmptyCommit("first commit")
- shell.CloneIntoSubmodule("my_submodule")
+ shell.CloneIntoSubmodule("my_submodule_name", "my_submodule_path")
shell.GitAddAll()
shell.Commit("add submodule")
@@ -31,22 +31,24 @@ var Reset = NewIntegrationTest(NewIntegrationTestArgs{
t.Views().Status().Content(Contains("repo"))
}
assertInSubmodule := func() {
- t.Views().Status().Content(Contains("my_submodule"))
+ if t.Git().Version().IsAtLeast(2, 22, 0) {
+ t.Views().Status().Content(Contains("my_submodule_path(my_submodule_name)"))
+ } else {
+ t.Views().Status().Content(Contains("my_submodule_path"))
+ }
}
assertInParentRepo()
t.Views().Submodules().Focus().
Lines(
- Contains("my_submodule").IsSelected(),
+ Contains("my_submodule_name").IsSelected(),
).
// enter the submodule
PressEnter()
assertInSubmodule()
- t.Views().Status().Content(Contains("my_submodule"))
-
t.Views().Files().IsFocused().
Press("e").
Tap(func() {
@@ -65,18 +67,18 @@ var Reset = NewIntegrationTest(NewIntegrationTestArgs{
t.Views().Submodules().IsFocused()
- t.Views().Main().Content(Contains("Submodule my_submodule contains modified content"))
+ t.Views().Main().Content(Contains("Submodule my_submodule_path contains modified content"))
t.Views().Files().Focus().
Lines(
- MatchesRegexp(` M.*my_submodule \(submodule\)`),
+ MatchesRegexp(` M.*my_submodule_path \(submodule\)`),
Contains("other_file").IsSelected(),
).
// Verify we can't use range select on submodules
Press(keys.Universal.ToggleRangeSelect).
SelectPreviousItem().
Lines(
- MatchesRegexp(` M.*my_submodule \(submodule\)`).IsSelected(),
+ MatchesRegexp(` M.*my_submodule_path \(submodule\)`).IsSelected(),
Contains("other_file").IsSelected(),
).
Press(keys.Universal.Remove).
@@ -85,13 +87,13 @@ var Reset = NewIntegrationTest(NewIntegrationTestArgs{
}).
Press(keys.Universal.ToggleRangeSelect).
Lines(
- MatchesRegexp(` M.*my_submodule \(submodule\)`).IsSelected(),
+ MatchesRegexp(` M.*my_submodule_path \(submodule\)`).IsSelected(),
Contains("other_file"),
).
Press(keys.Universal.Remove).
Tap(func() {
t.ExpectPopup().Menu().
- Title(Equals("my_submodule")).
+ Title(Equals("my_submodule_path")).
Select(Contains("Stash uncommitted submodule changes and update")).
Confirm()
}).
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"})
+}