mirror of
				https://github.com/jesseduffield/lazygit.git
				synced 2025-10-30 23:57:43 +02: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) | ||||
| 				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 | ||||
| 					} | ||||
|  | ||||
|   | ||||
| @@ -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", | ||||
|   | ||||
| @@ -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( | ||||
|   | ||||
| @@ -34,25 +34,13 @@ var ForceRemoveWorktreeWithSubmodules = NewIntegrationTest(NewIntegrationTestArg | ||||
| 					Content(Equals("Are you sure you want to remove worktree 'linked-worktree'?")). | ||||
| 					Confirm() | ||||
|  | ||||
| 				/* EXPECTED: | ||||
| 				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() | ||||
| 				ACTUAL: */ | ||||
| 				t.ExpectPopup().Alert(). | ||||
| 					Title(Equals("Error")). | ||||
| 					Content(Equals("fatal: working trees containing submodules cannot be moved or removed")). | ||||
| 					Confirm() | ||||
| 			}). | ||||
| 			/* EXPECTED: | ||||
| 			Lines( | ||||
| 				Contains("repo (main)").IsSelected(), | ||||
| 			) | ||||
| 			ACTUAL: */ | ||||
| 			Lines( | ||||
| 				Contains("repo (main)"), | ||||
| 				Contains("linked-worktree").IsSelected(), | ||||
| 			) | ||||
| 	}, | ||||
| }) | ||||
|   | ||||
| @@ -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( | ||||
|   | ||||
		Reference in New Issue
	
	Block a user