|
| 1 | +package worktree |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/jesseduffield/lazygit/pkg/config" |
| 5 | + . "github.com/jesseduffield/lazygit/pkg/integration/components" |
| 6 | +) |
| 7 | + |
| 8 | +var ForceRemoveWorktreeWithSubmodules = NewIntegrationTest(NewIntegrationTestArgs{ |
| 9 | + Description: "Force remove a worktree that contains submodules", |
| 10 | + ExtraCmdArgs: []string{}, |
| 11 | + Skip: false, |
| 12 | + SetupConfig: func(config *config.AppConfig) {}, |
| 13 | + SetupRepo: func(shell *Shell) { |
| 14 | + shell.NewBranch("mybranch") |
| 15 | + shell.CreateFileAndAdd("README.md", "hello world") |
| 16 | + shell.Commit("initial commit") |
| 17 | + shell.CloneIntoSubmodule("submodule", "submodule") |
| 18 | + shell.Commit("Add submodule") |
| 19 | + shell.AddWorktree("mybranch", "../linked-worktree", "newbranch") |
| 20 | + shell.RunCommand([]string{"git", "-C", "../linked-worktree", "submodule", "update", "--init"}) |
| 21 | + }, |
| 22 | + Run: func(t *TestDriver, keys config.KeybindingConfig) { |
| 23 | + t.Views().Worktrees(). |
| 24 | + Focus(). |
| 25 | + Lines( |
| 26 | + Contains("repo (main)").IsSelected(), |
| 27 | + Contains("linked-worktree"), |
| 28 | + ). |
| 29 | + NavigateToLine(Contains("linked-worktree")). |
| 30 | + Press(keys.Universal.Remove). |
| 31 | + Tap(func() { |
| 32 | + t.ExpectPopup().Confirmation(). |
| 33 | + Title(Equals("Remove worktree")). |
| 34 | + Content(Equals("Are you sure you want to remove worktree 'linked-worktree'?")). |
| 35 | + Confirm() |
| 36 | + |
| 37 | + /* EXPECTED: |
| 38 | + t.ExpectPopup().Confirmation(). |
| 39 | + Title(Equals("Remove worktree")). |
| 40 | + Content(Equals("'linked-worktree' contains modified or untracked files, or submodules (or all of these). Are you sure you want to remove it?")). |
| 41 | + Confirm() |
| 42 | + ACTUAL: */ |
| 43 | + t.ExpectPopup().Alert(). |
| 44 | + Title(Equals("Error")). |
| 45 | + Content(Equals("fatal: working trees containing submodules cannot be moved or removed")). |
| 46 | + Confirm() |
| 47 | + }). |
| 48 | + /* EXPECTED: |
| 49 | + Lines( |
| 50 | + Contains("repo (main)").IsSelected(), |
| 51 | + ) |
| 52 | + ACTUAL: */ |
| 53 | + Lines( |
| 54 | + Contains("repo (main)"), |
| 55 | + Contains("linked-worktree").IsSelected(), |
| 56 | + ) |
| 57 | + }, |
| 58 | +}) |
0 commit comments