diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2019-11-05 11:53:01 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2019-11-05 19:22:01 +1100 |
commit | 0ffccbd3ee952a441575f378ce70b8be94e9f3c5 (patch) | |
tree | 328525fdcdc9615fe95ada5399f7814d3c7565ce /pkg/gui/patch_options_panel.go | |
parent | 1fc120de2d4a28b976920cd3ac5393bf4c040705 (diff) |
checks for if we're in a normal working tree state
Diffstat (limited to 'pkg/gui/patch_options_panel.go')
-rw-r--r-- | pkg/gui/patch_options_panel.go | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/pkg/gui/patch_options_panel.go b/pkg/gui/patch_options_panel.go index 14d13cd82..5e2329703 100644 --- a/pkg/gui/patch_options_panel.go +++ b/pkg/gui/patch_options_panel.go @@ -54,7 +54,9 @@ func (gui *Gui) getPatchCommitIndex() int { } func (gui *Gui) handleDeletePatchFromCommit() error { - // TODO: deal with when we're already rebasing + if ok, err := gui.validateNormalWorkingTreeState(); !ok { + return err + } return gui.WithWaitingStatus(gui.Tr.SLocalize("RebasingStatus"), func() error { commitIndex := gui.getPatchCommitIndex() @@ -64,7 +66,9 @@ func (gui *Gui) handleDeletePatchFromCommit() error { } func (gui *Gui) handleMovePatchToSelectedCommit() error { - // TODO: deal with when we're already rebasing + if ok, err := gui.validateNormalWorkingTreeState(); !ok { + return err + } return gui.WithWaitingStatus(gui.Tr.SLocalize("RebasingStatus"), func() error { commitIndex := gui.getPatchCommitIndex() @@ -73,8 +77,17 @@ func (gui *Gui) handleMovePatchToSelectedCommit() error { }) } +func (gui *Gui) validateNormalWorkingTreeState() (bool, error) { + if gui.State.WorkingTreeState != "normal" { + return false, gui.createErrorPanel(gui.g, gui.Tr.SLocalize("CantPatchWhileRebasingError")) + } + return true, nil +} + func (gui *Gui) handlePullPatchIntoWorkingTree() error { - // TODO: deal with when we're already rebasing + if ok, err := gui.validateNormalWorkingTreeState(); !ok { + return err + } return gui.WithWaitingStatus(gui.Tr.SLocalize("RebasingStatus"), func() error { commitIndex := gui.getPatchCommitIndex() |