summaryrefslogtreecommitdiffstats
path: root/pkg/gui/patch_options_panel.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2019-11-05 11:53:01 +1100
committerJesse Duffield <jessedduffield@gmail.com>2019-11-05 19:22:01 +1100
commit0ffccbd3ee952a441575f378ce70b8be94e9f3c5 (patch)
tree328525fdcdc9615fe95ada5399f7814d3c7565ce /pkg/gui/patch_options_panel.go
parent1fc120de2d4a28b976920cd3ac5393bf4c040705 (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.go19
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()