Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pkg/gui/controllers/helpers/worktree_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ func (self *WorktreeHelper) Remove(worktree *models.Worktree, force bool) error
self.c.LogAction(self.c.Tr.RemoveWorktree)
if err := self.c.Git().Worktree.Delete(worktree.Path, force); err != nil {
errMessage := err.Error()
if !strings.Contains(errMessage, "--force") {
if !strings.Contains(errMessage, "--force") &&
!strings.Contains(errMessage, "fatal: working trees containing submodules cannot be moved or removed") {
return err
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/i18n/english.go
Original file line number Diff line number Diff line change
Expand Up @@ -1933,7 +1933,7 @@ func EnglishTranslationSet() *TranslationSet {
RemoveWorktree: "Remove worktree",
RemoveWorktreeTitle: "Remove worktree",
RemoveWorktreePrompt: "Are you sure you want to remove worktree '{{.worktreeName}}'?",
ForceRemoveWorktreePrompt: "'{{.worktreeName}}' contains modified or untracked files (to be honest, it could contain both). Are you sure you want to remove it?",
ForceRemoveWorktreePrompt: "'{{.worktreeName}}' contains modified or untracked files, or submodules (or all of these). Are you sure you want to remove it?",
RemovingWorktree: "Deleting worktree",
DetachWorktree: "Detach worktree",
DetachingWorktree: "Detaching worktree",
Expand Down
1 change: 1 addition & 0 deletions pkg/integration/tests/test_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ var tests = []*components.IntegrationTest{
worktree.FastForwardWorktreeBranch,
worktree.FastForwardWorktreeBranchShouldNotPolluteCurrentWorktree,
worktree.ForceRemoveWorktree,
worktree.ForceRemoveWorktreeWithSubmodules,
worktree.RemoveWorktreeFromBranch,
worktree.ResetWindowTabs,
worktree.SymlinkIntoRepoSubdir,
Expand Down
2 changes: 1 addition & 1 deletion pkg/integration/tests/worktree/force_remove_worktree.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var ForceRemoveWorktree = NewIntegrationTest(NewIntegrationTestArgs{

t.ExpectPopup().Confirmation().
Title(Equals("Remove worktree")).
Content(Equals("'linked-worktree' contains modified or untracked files (to be honest, it could contain both). Are you sure you want to remove it?")).
Content(Equals("'linked-worktree' contains modified or untracked files, or submodules (or all of these). Are you sure you want to remove it?")).
Confirm()
}).
Lines(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package worktree

import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)

var ForceRemoveWorktreeWithSubmodules = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Force remove a worktree that contains submodules",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.NewBranch("mybranch")
shell.CreateFileAndAdd("README.md", "hello world")
shell.Commit("initial commit")
shell.CloneIntoSubmodule("submodule", "submodule")
shell.Commit("Add submodule")
shell.AddWorktree("mybranch", "../linked-worktree", "newbranch")
shell.RunCommand([]string{"git", "-C", "../linked-worktree", "submodule", "update", "--init"})
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Worktrees().
Focus().
Lines(
Contains("repo (main)").IsSelected(),
Contains("linked-worktree"),
).
NavigateToLine(Contains("linked-worktree")).
Press(keys.Universal.Remove).
Tap(func() {
t.ExpectPopup().Confirmation().
Title(Equals("Remove worktree")).
Content(Equals("Are you sure you want to remove worktree 'linked-worktree'?")).
Confirm()

t.ExpectPopup().Confirmation().
Title(Equals("Remove worktree")).
Content(Equals("'linked-worktree' contains modified or untracked files, or submodules (or all of these). Are you sure you want to remove it?")).
Confirm()
}).
Lines(
Contains("repo (main)").IsSelected(),
)
},
})
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var RemoveWorktreeFromBranch = NewIntegrationTest(NewIntegrationTestArgs{

t.ExpectPopup().Confirmation().
Title(Equals("Remove worktree")).
Content(Equals("'linked-worktree' contains modified or untracked files (to be honest, it could contain both). Are you sure you want to remove it?")).
Content(Equals("'linked-worktree' contains modified or untracked files, or submodules (or all of these). Are you sure you want to remove it?")).
Confirm()
}).
Lines(
Expand Down