summaryrefslogtreecommitdiffstats
path: root/pkg/gui/commit_message_panel.go
diff options
context:
space:
mode:
authorJesse Duffield Duffield <jesseduffieldduffield@Jesses-MacBook-Pro-3.local>2019-02-24 09:42:24 +1100
committerJesse Duffield Duffield <jesseduffieldduffield@Jesses-MacBook-Pro-3.local>2019-02-24 10:58:15 +1100
commit95d451e59a419933f6e5f90305ffc6fe8dbc448f (patch)
tree25aba410c18655c6e59d80da4aef612c43193f7b /pkg/gui/commit_message_panel.go
parent6c1d2d45ef2d001e28ec31095826422ba7461664 (diff)
Make it easier to run sync/async commands, switch to interactive rebase when rebasing on branches
Diffstat (limited to 'pkg/gui/commit_message_panel.go')
-rw-r--r--pkg/gui/commit_message_panel.go26
1 files changed, 18 insertions, 8 deletions
diff --git a/pkg/gui/commit_message_panel.go b/pkg/gui/commit_message_panel.go
index 130ec3401..b05a7df6c 100644
--- a/pkg/gui/commit_message_panel.go
+++ b/pkg/gui/commit_message_panel.go
@@ -1,28 +1,38 @@
package gui
import (
+ "os/exec"
"strconv"
"strings"
"github.com/jesseduffield/gocui"
)
-func (gui *Gui) handleCommitConfirm(g *gocui.Gui, v *gocui.View) error {
- message := gui.trimmedContent(v)
- if message == "" {
- return gui.createErrorPanel(g, gui.Tr.SLocalize("CommitWithoutMessageErr"))
- }
- sub, err := gui.GitCommand.Commit(message, false)
+// runSyncOrAsyncCommand takes the output of a command that may have returned
+// either no error, an error, or a subprocess to execute, and if a subprocess
+// needs to be set on the gui object, it does so, and then returns the error
+func (gui *Gui) runSyncOrAsyncCommand(sub *exec.Cmd, err error) error {
if err != nil {
- // TODO need to find a way to send through this error
if err != gui.Errors.ErrSubProcess {
- return gui.createErrorPanel(g, err.Error())
+ return gui.createErrorPanel(gui.g, err.Error())
}
}
if sub != nil {
gui.SubProcess = sub
return gui.Errors.ErrSubProcess
}
+ return nil
+}
+
+func (gui *Gui) handleCommitConfirm(g *gocui.Gui, v *gocui.View) error {
+ message := gui.trimmedContent(v)
+ if message == "" {
+ return gui.createErrorPanel(g, gui.Tr.SLocalize("CommitWithoutMessageErr"))
+ }
+ if err := gui.runSyncOrAsyncCommand(gui.GitCommand.Commit(message)); err != nil {
+ return err
+ }
+
v.Clear()
_ = v.SetCursor(0, 0)
_ = v.SetOrigin(0, 0)