summaryrefslogtreecommitdiffstats
path: root/pkg/gui/commit_message_panel.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2019-03-23 12:16:55 +1100
committerJesse Duffield <jessedduffield@gmail.com>2019-03-23 13:07:36 +1100
commita2c780b085b4b5fecf387d4f848d562494ab51cc (patch)
tree9e5e2d4400621c617d7d5ba3a023428e92b5baa1 /pkg/gui/commit_message_panel.go
parentb99305c909b891a0bc49050e48d48d1f4af55580 (diff)
retain commit message if precommit hook fails
Diffstat (limited to 'pkg/gui/commit_message_panel.go')
-rw-r--r--pkg/gui/commit_message_panel.go15
1 files changed, 10 insertions, 5 deletions
diff --git a/pkg/gui/commit_message_panel.go b/pkg/gui/commit_message_panel.go
index b05a7df6c..0f7e4ffcc 100644
--- a/pkg/gui/commit_message_panel.go
+++ b/pkg/gui/commit_message_panel.go
@@ -11,17 +11,18 @@ import (
// 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 {
+// the bool returned tells us whether the calling code should continue
+func (gui *Gui) runSyncOrAsyncCommand(sub *exec.Cmd, err error) (bool, error) {
if err != nil {
if err != gui.Errors.ErrSubProcess {
- return gui.createErrorPanel(gui.g, err.Error())
+ return false, gui.createErrorPanel(gui.g, err.Error())
}
}
if sub != nil {
gui.SubProcess = sub
- return gui.Errors.ErrSubProcess
+ return false, gui.Errors.ErrSubProcess
}
- return nil
+ return true, nil
}
func (gui *Gui) handleCommitConfirm(g *gocui.Gui, v *gocui.View) error {
@@ -29,9 +30,13 @@ func (gui *Gui) handleCommitConfirm(g *gocui.Gui, v *gocui.View) error {
if message == "" {
return gui.createErrorPanel(g, gui.Tr.SLocalize("CommitWithoutMessageErr"))
}
- if err := gui.runSyncOrAsyncCommand(gui.GitCommand.Commit(message)); err != nil {
+ ok, err := gui.runSyncOrAsyncCommand(gui.GitCommand.Commit(message))
+ if err != nil {
return err
}
+ if !ok {
+ return nil
+ }
v.Clear()
_ = v.SetCursor(0, 0)