From b1918f2f688891efd34a190a210f10ec35c160f3 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Mon, 6 Aug 2018 18:55:08 +1000 Subject: [PATCH] no panic on git commit error --- files_panel.go | 4 ++-- gitcommands.go | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/files_panel.go b/files_panel.go index ad4f9e809..50d6b64e2 100644 --- a/files_panel.go +++ b/files_panel.go @@ -160,8 +160,8 @@ func handleCommitPress(g *gocui.Gui, filesView *gocui.View) error { if message == "" { return createErrorPanel(g, "You cannot commit without a commit message") } - if err := gitCommit(message); err != nil { - panic(err) + if output, err := gitCommit(message); err != nil { + return createErrorPanel(g, output) } refreshFiles(g) return refreshCommits(g) diff --git a/gitcommands.go b/gitcommands.go index 719a8ceb0..d537672a0 100644 --- a/gitcommands.go +++ b/gitcommands.go @@ -445,9 +445,8 @@ func removeFile(file GitFile) error { return err } -func gitCommit(message string) error { - _, err := runDirectCommand("git commit -m \"" + message + "\"") - return err +func gitCommit(message string) (string, error) { + return runCommand("git commit -m \"" + message + "\"") } func gitPull() (string, error) {