diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2019-11-17 14:04:57 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2019-11-21 22:07:14 +1100 |
commit | dcb52857976762378b0e69bd45581231aa334482 (patch) | |
tree | bb8bd788b151d503f3b3a3cbc93aaeef93bec2b4 | |
parent | a9cd647075119c760ca22cceba8c4ad14687b732 (diff) |
support rebasing onto remote branch
-rw-r--r-- | pkg/gui/branches_panel.go | 19 | ||||
-rw-r--r-- | pkg/gui/keybindings.go | 10 | ||||
-rw-r--r-- | pkg/gui/remote_branches_panel.go | 5 | ||||
-rw-r--r-- | pkg/i18n/english.go | 2 |
4 files changed, 26 insertions, 10 deletions
diff --git a/pkg/gui/branches_panel.go b/pkg/gui/branches_panel.go index dabe995cb..ca7ca23e8 100644 --- a/pkg/gui/branches_panel.go +++ b/pkg/gui/branches_panel.go @@ -304,23 +304,26 @@ func (gui *Gui) handleMerge(g *gocui.Gui, v *gocui.View) error { 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 - selectedBranch := gui.getSelectedBranch().Name - if selectedBranch == checkedOutBranch { - return gui.createErrorPanel(g, gui.Tr.SLocalize("CantRebaseOntoSelf")) + if selectedBranchName == checkedOutBranch { + return gui.createErrorPanel(gui.g, gui.Tr.SLocalize("CantRebaseOntoSelf")) } prompt := gui.Tr.TemplateLocalize( "ConfirmRebase", Teml{ "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 { - - err := gui.GitCommand.RebaseBranch(selectedBranch) + err := gui.GitCommand.RebaseBranch(selectedBranchName) return gui.handleGenericMergeCommandResult(err) }, nil) } diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index 88e35bc5c..85678b6ad 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -383,7 +383,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { Contexts: []string{"local-branches"}, Key: 'r', Modifier: gocui.ModNone, - Handler: gui.handleRebase, + Handler: gui.handleRebaseOntoLocalBranch, Description: gui.Tr.SLocalize("rebaseBranch"), }, { @@ -1082,6 +1082,14 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { 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", Key: gocui.MouseLeft, Modifier: gocui.ModNone, diff --git a/pkg/gui/remote_branches_panel.go b/pkg/gui/remote_branches_panel.go index e53e716c5..c1534c89a 100644 --- a/pkg/gui/remote_branches_panel.go +++ b/pkg/gui/remote_branches_panel.go @@ -114,3 +114,8 @@ func (gui *Gui) handleDeleteRemoteBranch(g *gocui.Gui, v *gocui.View) error { }) }, nil) } + +func (gui *Gui) handleRebaseOntoRemoteBranch(g *gocui.Gui, v *gocui.View) error { + selectedBranchName := gui.getSelectedRemoteBranch().Name + return gui.handleRebaseOntoBranch(selectedBranchName) +} diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index a41eb2fc1..736bf9162 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -221,7 +221,7 @@ func addEnglish(i18nObject *i18n.Bundle) error { Other: "{{.selectedBranchName}} is not fully merged. Are you sure you want to delete it?", }, &i18n.Message{ ID: "rebaseBranch", - Other: "rebase branch", + Other: "rebase checked-out branch onto this branch", }, &i18n.Message{ ID: "CantRebaseOntoSelf", Other: "You cannot rebase a branch onto itself", |