1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
package worktree
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
// Even though this involves submodules, it's a worktree test since
// it's really exercising lazygit's ability to correctly do pathfinding
// in a complex use case.
var DoubleNestedLinkedSubmodule = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Open lazygit in a link to a repo's double nested submodules",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {
config.GetUserConfig().Gui.ShowFileTree = false
},
SetupRepo: func(shell *Shell) {
// we're going to have a directory structure like this:
// project
// - repo/outerSubmodule/innerSubmodule/a/b/c
// - link (symlink to repo/outerSubmodule/innerSubmodule/a/b/c)
//
shell.CreateFileAndAdd("rootFile", "rootStuff")
shell.Commit("initial repo commit")
shell.Chdir("..")
shell.CreateDir("innerSubmodule")
shell.Chdir("innerSubmodule")
shell.Init()
shell.CreateFileAndAdd("a/b/c/blah", "blah\n")
shell.Commit("initial inner commit")
shell.Chdir("..")
shell.CreateDir("outerSubmodule")
shell.Chdir("outerSubmodule")
shell.Init()
shell.CreateFileAndAdd("foo", "foo")
shell.Commit("initial outer commit")
// 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", "../innerSubmodule"})
shell.Commit("add dependency as innerSubmodule")
shell.Chdir("../repo")
shell.RunCommand([]string{"git", "-c", "protocol.file.allow=always", "submodule", "add", "../outerSubmodule"})
shell.Commit("add dependency as outerSubmodule")
shell.Chdir("outerSubmodule")
shell.RunCommand([]string{"git", "-c", "protocol.file.allow=always", "submodule", "update", "--init", "--recursive"})
shell.Chdir("innerSubmodule")
shell.UpdateFile("a/b/c/blah", "updated content\n")
shell.Chdir("../../..")
shell.RunCommand([]string{"ln", "-s", "repo/outerSubmodule/innerSubmodule/a/b/c", "link"})
shell.Chdir("link")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Branches().
Lines(
Contains("HEAD detached"),
Contains("master"),
)
t.Views().Commits().
Lines(
Contains("initial inner commit"),
)
t.Views().Files().
IsFocused().
Lines(
Contains(" M a/b/c/blah"), // shows as modified
).
PressPrimaryAction().
Press(keys.Files.CommitChanges)
t.ExpectPopup().CommitMessagePanel().
Title(Equals("Commit summary")).
Type("Update blah").
Confirm()
t.Views().Files().
IsEmpty()
t.Views().Commits().
Lines(
Contains("Update blah"),
Contains("initial inner commit"),
)
},
})
|