mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-01-03 22:39:23 +03:00
Offer to force-delete a worktree if it contains submodules
This commit is contained in:
@@ -189,7 +189,8 @@ func (self *WorktreeHelper) Remove(worktree *models.Worktree, force bool) error
|
|||||||
self.c.LogAction(self.c.Tr.RemoveWorktree)
|
self.c.LogAction(self.c.Tr.RemoveWorktree)
|
||||||
if err := self.c.Git().Worktree.Delete(worktree.Path, force); err != nil {
|
if err := self.c.Git().Worktree.Delete(worktree.Path, force); err != nil {
|
||||||
errMessage := err.Error()
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1933,7 +1933,7 @@ func EnglishTranslationSet() *TranslationSet {
|
|||||||
RemoveWorktree: "Remove worktree",
|
RemoveWorktree: "Remove worktree",
|
||||||
RemoveWorktreeTitle: "Remove worktree",
|
RemoveWorktreeTitle: "Remove worktree",
|
||||||
RemoveWorktreePrompt: "Are you sure you want to remove worktree '{{.worktreeName}}'?",
|
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",
|
RemovingWorktree: "Deleting worktree",
|
||||||
DetachWorktree: "Detach worktree",
|
DetachWorktree: "Detach worktree",
|
||||||
DetachingWorktree: "Detaching worktree",
|
DetachingWorktree: "Detaching worktree",
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ var ForceRemoveWorktree = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
|
|
||||||
t.ExpectPopup().Confirmation().
|
t.ExpectPopup().Confirmation().
|
||||||
Title(Equals("Remove worktree")).
|
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()
|
Confirm()
|
||||||
}).
|
}).
|
||||||
Lines(
|
Lines(
|
||||||
|
|||||||
@@ -34,25 +34,13 @@ var ForceRemoveWorktreeWithSubmodules = NewIntegrationTest(NewIntegrationTestArg
|
|||||||
Content(Equals("Are you sure you want to remove worktree 'linked-worktree'?")).
|
Content(Equals("Are you sure you want to remove worktree 'linked-worktree'?")).
|
||||||
Confirm()
|
Confirm()
|
||||||
|
|
||||||
/* EXPECTED:
|
|
||||||
t.ExpectPopup().Confirmation().
|
t.ExpectPopup().Confirmation().
|
||||||
Title(Equals("Remove worktree")).
|
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?")).
|
Content(Equals("'linked-worktree' contains modified or untracked files, or submodules (or all of these). Are you sure you want to remove it?")).
|
||||||
Confirm()
|
Confirm()
|
||||||
ACTUAL: */
|
|
||||||
t.ExpectPopup().Alert().
|
|
||||||
Title(Equals("Error")).
|
|
||||||
Content(Equals("fatal: working trees containing submodules cannot be moved or removed")).
|
|
||||||
Confirm()
|
|
||||||
}).
|
}).
|
||||||
/* EXPECTED:
|
|
||||||
Lines(
|
Lines(
|
||||||
Contains("repo (main)").IsSelected(),
|
Contains("repo (main)").IsSelected(),
|
||||||
)
|
)
|
||||||
ACTUAL: */
|
|
||||||
Lines(
|
|
||||||
Contains("repo (main)"),
|
|
||||||
Contains("linked-worktree").IsSelected(),
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ var RemoveWorktreeFromBranch = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
|
|
||||||
t.ExpectPopup().Confirmation().
|
t.ExpectPopup().Confirmation().
|
||||||
Title(Equals("Remove worktree")).
|
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()
|
Confirm()
|
||||||
}).
|
}).
|
||||||
Lines(
|
Lines(
|
||||||
|
|||||||
Reference in New Issue
Block a user