mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-31 14:24:25 +03:00
support rebasing onto remote branch
This commit is contained in:
@ -304,23 +304,26 @@ func (gui *Gui) handleMerge(g *gocui.Gui, v *gocui.View) error {
|
|||||||
return gui.mergeBranchIntoCheckedOutBranch(selectedBranchName)
|
return gui.mergeBranchIntoCheckedOutBranch(selectedBranchName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) handleRebase(g *gocui.Gui, v *gocui.View) error {
|
func (gui *Gui) handleRebaseOntoLocalBranch(g *gocui.Gui, v *gocui.View) error {
|
||||||
|
selectedBranchName := gui.getSelectedBranch().Name
|
||||||
|
return gui.handleRebaseOntoBranch(selectedBranchName)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (gui *Gui) handleRebaseOntoBranch(selectedBranchName string) error {
|
||||||
checkedOutBranch := gui.State.Branches[0].Name
|
checkedOutBranch := gui.State.Branches[0].Name
|
||||||
selectedBranch := gui.getSelectedBranch().Name
|
if selectedBranchName == checkedOutBranch {
|
||||||
if selectedBranch == checkedOutBranch {
|
return gui.createErrorPanel(gui.g, gui.Tr.SLocalize("CantRebaseOntoSelf"))
|
||||||
return gui.createErrorPanel(g, gui.Tr.SLocalize("CantRebaseOntoSelf"))
|
|
||||||
}
|
}
|
||||||
prompt := gui.Tr.TemplateLocalize(
|
prompt := gui.Tr.TemplateLocalize(
|
||||||
"ConfirmRebase",
|
"ConfirmRebase",
|
||||||
Teml{
|
Teml{
|
||||||
"checkedOutBranch": checkedOutBranch,
|
"checkedOutBranch": checkedOutBranch,
|
||||||
"selectedBranch": selectedBranch,
|
"selectedBranch": selectedBranchName,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
return gui.createConfirmationPanel(g, v, true, gui.Tr.SLocalize("RebasingTitle"), prompt,
|
return gui.createConfirmationPanel(gui.g, gui.getBranchesView(), true, gui.Tr.SLocalize("RebasingTitle"), prompt,
|
||||||
func(g *gocui.Gui, v *gocui.View) error {
|
func(g *gocui.Gui, v *gocui.View) error {
|
||||||
|
err := gui.GitCommand.RebaseBranch(selectedBranchName)
|
||||||
err := gui.GitCommand.RebaseBranch(selectedBranch)
|
|
||||||
return gui.handleGenericMergeCommandResult(err)
|
return gui.handleGenericMergeCommandResult(err)
|
||||||
}, nil)
|
}, nil)
|
||||||
}
|
}
|
||||||
|
@ -383,7 +383,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
|||||||
Contexts: []string{"local-branches"},
|
Contexts: []string{"local-branches"},
|
||||||
Key: 'r',
|
Key: 'r',
|
||||||
Modifier: gocui.ModNone,
|
Modifier: gocui.ModNone,
|
||||||
Handler: gui.handleRebase,
|
Handler: gui.handleRebaseOntoLocalBranch,
|
||||||
Description: gui.Tr.SLocalize("rebaseBranch"),
|
Description: gui.Tr.SLocalize("rebaseBranch"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -1081,6 +1081,14 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
|||||||
Handler: gui.handleDeleteRemoteBranch,
|
Handler: gui.handleDeleteRemoteBranch,
|
||||||
Description: gui.Tr.SLocalize("deleteBranch"),
|
Description: gui.Tr.SLocalize("deleteBranch"),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
ViewName: "branches",
|
||||||
|
Contexts: []string{"remote-branches"},
|
||||||
|
Key: 'r',
|
||||||
|
Modifier: gocui.ModNone,
|
||||||
|
Handler: gui.handleRebaseOntoRemoteBranch,
|
||||||
|
Description: gui.Tr.SLocalize("rebaseBranch"),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
ViewName: "commits",
|
ViewName: "commits",
|
||||||
Key: gocui.MouseLeft,
|
Key: gocui.MouseLeft,
|
||||||
|
@ -114,3 +114,8 @@ func (gui *Gui) handleDeleteRemoteBranch(g *gocui.Gui, v *gocui.View) error {
|
|||||||
})
|
})
|
||||||
}, nil)
|
}, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (gui *Gui) handleRebaseOntoRemoteBranch(g *gocui.Gui, v *gocui.View) error {
|
||||||
|
selectedBranchName := gui.getSelectedRemoteBranch().Name
|
||||||
|
return gui.handleRebaseOntoBranch(selectedBranchName)
|
||||||
|
}
|
||||||
|
@ -221,7 +221,7 @@ func addEnglish(i18nObject *i18n.Bundle) error {
|
|||||||
Other: "{{.selectedBranchName}} is not fully merged. Are you sure you want to delete it?",
|
Other: "{{.selectedBranchName}} is not fully merged. Are you sure you want to delete it?",
|
||||||
}, &i18n.Message{
|
}, &i18n.Message{
|
||||||
ID: "rebaseBranch",
|
ID: "rebaseBranch",
|
||||||
Other: "rebase branch",
|
Other: "rebase checked-out branch onto this branch",
|
||||||
}, &i18n.Message{
|
}, &i18n.Message{
|
||||||
ID: "CantRebaseOntoSelf",
|
ID: "CantRebaseOntoSelf",
|
||||||
Other: "You cannot rebase a branch onto itself",
|
Other: "You cannot rebase a branch onto itself",
|
||||||
|
Reference in New Issue
Block a user