diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2019-02-18 23:27:54 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2019-02-18 23:27:54 +1100 |
commit | d44638130c8d07c648b45796cc6b0dff221c7d82 (patch) | |
tree | 71b1bfdc271de1cac8fffe223d23fe7295c0158d /pkg/gui/commits_panel.go | |
parent | 76a27f417fc7fd24b4fdf12f0aeeb94ecca958d3 (diff) |
add various interactive rebase commands
Diffstat (limited to 'pkg/gui/commits_panel.go')
-rw-r--r-- | pkg/gui/commits_panel.go | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go index 4bf0d4362..374f7ccf0 100644 --- a/pkg/gui/commits_panel.go +++ b/pkg/gui/commits_panel.go @@ -181,17 +181,45 @@ func (gui *Gui) handleRenameCommit(g *gocui.Gui, v *gocui.View) error { } func (gui *Gui) handleRenameCommitEditor(g *gocui.Gui, v *gocui.View) error { - subProcess, err := gui.GitCommand.InteractiveRebase(gui.State.Commits, gui.State.Panels.Commits.SelectedLine, "reword") + subProcess, err := gui.GitCommand.RewordCommit(gui.State.Commits, gui.State.Panels.Commits.SelectedLine) if err != nil { - return err + return gui.createErrorPanel(gui.g, err.Error()) } if subProcess != nil { gui.SubProcess = subProcess - // g.Update(func(g *gocui.Gui) error { - // return gui.Errors.ErrSubProcess - // }) return gui.Errors.ErrSubProcess } return nil } + +func (gui *Gui) handleCommitDelete(g *gocui.Gui, v *gocui.View) error { + // TODO: i18n + return gui.createConfirmationPanel(gui.g, v, "Delete Commit", "Are you sure you want to delete this commit?", func(*gocui.Gui, *gocui.View) error { + err := gui.GitCommand.InteractiveRebase(gui.State.Commits, gui.State.Panels.Commits.SelectedLine, "drop") + return gui.handleGenericMergeCommandResult(err) + }, nil) +} + +func (gui *Gui) handleCommitMoveDown(g *gocui.Gui, v *gocui.View) error { + gui.State.Panels.Commits.SelectedLine++ + + err := gui.GitCommand.MoveCommitDown(gui.State.Commits, gui.State.Panels.Commits.SelectedLine-1) + return gui.handleGenericMergeCommandResult(err) +} + +func (gui *Gui) handleCommitMoveUp(g *gocui.Gui, v *gocui.View) error { + if gui.State.Panels.Commits.SelectedLine == 0 { + return gui.createErrorPanel(gui.g, "You cannot move the topmost commit up") // TODO: i18n + } + + gui.State.Panels.Commits.SelectedLine-- + + err := gui.GitCommand.MoveCommitDown(gui.State.Commits, gui.State.Panels.Commits.SelectedLine) + return gui.handleGenericMergeCommandResult(err) +} + +func (gui *Gui) handleCommitEdit(g *gocui.Gui, v *gocui.View) error { + err := gui.GitCommand.InteractiveRebase(gui.State.Commits, gui.State.Panels.Commits.SelectedLine, "edit") + return gui.handleGenericMergeCommandResult(err) +} |