diff options
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/gui/branches_panel.go | 11 | ||||
-rw-r--r-- | pkg/gui/keybindings.go | 6 | ||||
-rw-r--r-- | pkg/i18n/english.go | 2 |
3 files changed, 11 insertions, 8 deletions
diff --git a/pkg/gui/branches_panel.go b/pkg/gui/branches_panel.go index 11a4a0ebb..dbf4b007a 100644 --- a/pkg/gui/branches_panel.go +++ b/pkg/gui/branches_panel.go @@ -87,6 +87,10 @@ func (gui *Gui) deleteBranch(g *gocui.Gui, v *gocui.View, force bool) error { if checkedOutBranch.Name == selectedBranch.Name { return gui.createErrorPanel(g, gui.Tr.SLocalize("CantDeleteCheckOutBranch")) } + return gui.deleteNamedBranch(g, v, selectedBranch, force) +} + +func (gui *Gui) deleteNamedBranch(g *gocui.Gui, v *gocui.View, selectedBranch *commands.Branch, force bool) error { title := gui.Tr.SLocalize("DeleteBranch") var messageId string if force { @@ -102,7 +106,12 @@ func (gui *Gui) deleteBranch(g *gocui.Gui, v *gocui.View, force bool) error { ) return gui.createConfirmationPanel(g, v, title, message, func(g *gocui.Gui, v *gocui.View) error { if err := gui.GitCommand.DeleteBranch(selectedBranch.Name, force); err != nil { - return gui.createErrorPanel(g, err.Error()) + errMessage := err.Error() + if !force && strings.Contains(errMessage, "is not fully merged") { + return gui.deleteNamedBranch(g, v, selectedBranch, true) + } else { + return gui.createErrorPanel(g, errMessage) + } } return gui.refreshSidePanels(g) }, nil) diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index 4a8995d5f..e460e4a1c 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -309,12 +309,6 @@ func (gui *Gui) GetKeybindings() []*Binding { Description: gui.Tr.SLocalize("deleteBranch"), }, { ViewName: "branches", - Key: 'D', - Modifier: gocui.ModNone, - Handler: gui.handleForceDeleteBranch, - Description: gui.Tr.SLocalize("forceDeleteBranch"), - }, { - ViewName: "branches", Key: 'm', Modifier: gocui.ModNone, Handler: gui.handleMerge, diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 52c2f993a..dc4e1537c 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -185,7 +185,7 @@ func addEnglish(i18nObject *i18n.Bundle) error { Other: "Are you sure you want to delete the branch {{.selectedBranchName}}?", }, &i18n.Message{ ID: "ForceDeleteBranchMessage", - Other: "Are you sure you want to force delete the branch {{.selectedBranchName}}?", + Other: "{{.selectedBranchName}} is not fully merged. Are you sure you want to delete it?", }, &i18n.Message{ ID: "CantMergeBranchIntoItself", Other: "You cannot merge a branch into itself", |