mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-19 22:33:16 +02:00
Merge pull request #301 from rozuur/master
Initial version of delete named branch added
This commit is contained in:
commit
c6da4c8a47
@ -87,6 +87,10 @@ func (gui *Gui) deleteBranch(g *gocui.Gui, v *gocui.View, force bool) error {
|
|||||||
if checkedOutBranch.Name == selectedBranch.Name {
|
if checkedOutBranch.Name == selectedBranch.Name {
|
||||||
return gui.createErrorPanel(g, gui.Tr.SLocalize("CantDeleteCheckOutBranch"))
|
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")
|
title := gui.Tr.SLocalize("DeleteBranch")
|
||||||
var messageId string
|
var messageId string
|
||||||
if force {
|
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 {
|
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 {
|
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)
|
return gui.refreshSidePanels(g)
|
||||||
}, nil)
|
}, nil)
|
||||||
|
@ -307,12 +307,6 @@ func (gui *Gui) GetKeybindings() []*Binding {
|
|||||||
Modifier: gocui.ModNone,
|
Modifier: gocui.ModNone,
|
||||||
Handler: gui.handleDeleteBranch,
|
Handler: gui.handleDeleteBranch,
|
||||||
Description: gui.Tr.SLocalize("deleteBranch"),
|
Description: gui.Tr.SLocalize("deleteBranch"),
|
||||||
}, {
|
|
||||||
ViewName: "branches",
|
|
||||||
Key: 'D',
|
|
||||||
Modifier: gocui.ModNone,
|
|
||||||
Handler: gui.handleForceDeleteBranch,
|
|
||||||
Description: gui.Tr.SLocalize("forceDeleteBranch"),
|
|
||||||
}, {
|
}, {
|
||||||
ViewName: "branches",
|
ViewName: "branches",
|
||||||
Key: 'm',
|
Key: 'm',
|
||||||
|
@ -176,7 +176,7 @@ func addEnglish(i18nObject *i18n.Bundle) error {
|
|||||||
Other: "Are you sure you want to delete the branch {{.selectedBranchName}}?",
|
Other: "Are you sure you want to delete the branch {{.selectedBranchName}}?",
|
||||||
}, &i18n.Message{
|
}, &i18n.Message{
|
||||||
ID: "ForceDeleteBranchMessage",
|
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{
|
}, &i18n.Message{
|
||||||
ID: "CantMergeBranchIntoItself",
|
ID: "CantMergeBranchIntoItself",
|
||||||
Other: "You cannot merge a branch into itself",
|
Other: "You cannot merge a branch into itself",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user