Skip to content

Commit

Permalink
Added rebase handler
Browse files Browse the repository at this point in the history
  • Loading branch information
glvr182 authored and jesseduffield committed Dec 10, 2018
1 parent 670f0e3 commit 27994f7
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions pkg/gui/branches_panel.go
Original file line number Diff line number Diff line change
@@ -94,6 +94,27 @@ func (gui *Gui) handleBranchesPrevLine(g *gocui.Gui, v *gocui.View) error {

// specific functions

func (gui *Gui) handleRebase(g *gocui.Gui, v *gocui.View) error {

selectedBranch := gui.getSelectedBranch(v).Name
checkedOutBranch := gui.State.Branches[0].Name
title := "Rebasing"
prompt := fmt.Sprintf("Are you sure you want to rebase %s onto %s?", checkedOutBranch, selectedBranch)

return gui.createConfirmationPanel(g, v, title, prompt,
func(g *gocui.Gui, v *gocui.View) error {
if selectedBranch == checkedOutBranch {
return gui.createErrorPanel(g, gui.Tr.SLocalize("CantRebaseOntoSelf"))
}
if err := gui.GitCommand.RebaseBranch(selectedBranch); err != nil {
gui.createErrorPanel(g, "Failed to rebase")
return gui.GitCommand.AbortRebaseBranch()
}

return gui.refreshSidePanels(g)
}, nil)
}

func (gui *Gui) handleBranchPress(g *gocui.Gui, v *gocui.View) error {
if gui.State.Panels.Branches.SelectedLine == -1 {
return nil

0 comments on commit 27994f7

Please sign in to comment.