Skip to content

Commit

Permalink
add reset to reflog commit menu
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseduffield committed Feb 15, 2020
1 parent feaf98b commit 0a69c1a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 67 deletions.
10 changes: 0 additions & 10 deletions pkg/gui/patch_options_panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,6 @@ import (
"github.com/jesseduffield/gocui"
)

type patchMenuOption struct {
displayName string
function func() error
}

// GetDisplayStrings is a function.
func (o *patchMenuOption) GetDisplayStrings(isFocused bool) []string {
return []string{o.displayName}
}

func (gui *Gui) handleCreatePatchOptionsMenu(g *gocui.Gui, v *gocui.View) error {
if !gui.GitCommand.PatchManager.CommitSelected() {
return gui.createErrorPanel(gui.g, gui.Tr.SLocalize("NoPatchError"))
Expand Down
6 changes: 6 additions & 0 deletions pkg/gui/reflog_panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,9 @@ func (gui *Gui) handleCheckoutReflogCommit(g *gocui.Gui, v *gocui.View) error {

return nil
}

func (gui *Gui) handleCreateReflogResetMenu(g *gocui.Gui, v *gocui.View) error {
commit := gui.getSelectedReflogCommit()

return gui.createResetMenu(commit.Sha)
}
55 changes: 0 additions & 55 deletions pkg/gui/reflog_reset_options_panel.go

This file was deleted.

7 changes: 5 additions & 2 deletions pkg/gui/reset_menu_panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ func (gui *Gui) createResetMenu(ref string) error {
},
onPress: func() error {
if err := gui.GitCommand.ResetToCommit(ref, innerStrength); err != nil {
return err
return gui.createErrorPanel(gui.g, err.Error())
}

gui.switchCommitsPanelContext("branch-commits")
gui.State.Panels.Commits.SelectedLine = 0
gui.State.Panels.ReflogCommits.SelectedLine = 0

if err := gui.refreshCommits(gui.g); err != nil {
return err
}
Expand All @@ -33,7 +37,6 @@ func (gui *Gui) createResetMenu(ref string) error {
return err
}

gui.State.Panels.Commits.SelectedLine = 0
return gui.handleCommitSelect(gui.g, gui.getCommitsView())
},
}
Expand Down

0 comments on commit 0a69c1a

Please sign in to comment.