diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2020-02-14 23:08:27 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2020-02-15 08:47:36 +1100 |
commit | c9714600e832875533fd1d2f4cbe615452727e05 (patch) | |
tree | 2fd65e1733ab0d208016b0da204a774fc7b9dcef /pkg/gui/commits_panel.go | |
parent | 665fdded145599d5eb96dd7d61520afea5aa31b1 (diff) |
refactor commit reset menu
Diffstat (limited to 'pkg/gui/commits_panel.go')
-rw-r--r-- | pkg/gui/commits_panel.go | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go index d25d9b239..43b3cb802 100644 --- a/pkg/gui/commits_panel.go +++ b/pkg/gui/commits_panel.go @@ -1,10 +1,8 @@ package gui import ( - "fmt" "strconv" - "github.com/fatih/color" "github.com/go-errors/errors" "github.com/jesseduffield/gocui" @@ -560,53 +558,6 @@ func (gui *Gui) handleSquashAllAboveFixupCommits(g *gocui.Gui, v *gocui.View) er }, nil) } -type resetOption struct { - description string - command string -} - -// GetDisplayStrings is a function. -func (r *resetOption) GetDisplayStrings(isFocused bool) []string { - return []string{r.description, color.New(color.FgRed).Sprint(r.command)} -} - -func (gui *Gui) handleCreateCommitResetMenu(g *gocui.Gui, v *gocui.View) error { - commit := gui.getSelectedCommit(g) - if commit == nil { - return gui.createErrorPanel(gui.g, gui.Tr.SLocalize("NoCommitsThisBranch")) - } - - strengths := []string{"soft", "mixed", "hard"} - options := make([]*resetOption, len(strengths)) - for i, strength := range strengths { - options[i] = &resetOption{ - description: fmt.Sprintf("%s reset", strength), - command: fmt.Sprintf("reset --%s %s", strength, commit.Sha), - } - } - - handleMenuPress := func(index int) error { - if err := gui.GitCommand.ResetToCommit(commit.Sha, strengths[index]); err != nil { - return err - } - - if err := gui.refreshCommits(g); err != nil { - return err - } - if err := gui.refreshFiles(); err != nil { - return err - } - if err := gui.resetOrigin(gui.getCommitsView()); err != nil { - return err - } - - gui.State.Panels.Commits.SelectedLine = 0 - return gui.handleCommitSelect(g, gui.getCommitsView()) - } - - return gui.createMenu(fmt.Sprintf("%s %s", gui.Tr.SLocalize("resetTo"), commit.Sha), options, len(options), handleMenuPress) -} - func (gui *Gui) handleTagCommit(g *gocui.Gui, v *gocui.View) error { // TODO: bring up menu asking if you want to make a lightweight or annotated tag // if annotated, switch to a subprocess to create the message |